How to change frame of a clip with code?

I’m using 1.19

I’m trying to find a way to change the frame of a clip (on single frame) through code

I have tried this.currentframenumber = n and this.currentframename but both of them do not work

Hi, welcome to The Forums! Can you please explain more in detail what you need?

I’m trying to make a game where if you input in the wrong time it goes to a frame in the clip which sais miss and if you input at the right time it goes to a frame which sais hit

Add this in the clip:

this.gotoAndStop(?);

Make sure to replace the “?” with the frame number you want the clip to go to

(Is this what you mean?)

does this work if i use it in the main scene?
if so, thank you

1 Like


it doesn’t work for me

Try project.gotoAndStop(2) instead

sorry for the misunderstanding, i meant the frames of the clip itself
I have tried this.gotoAndStop(int) player.gotoAndStop(int) but both don’t work

That’s odd, it’s supposed to work?
The problem might be else where in your code (maybe a redefinition of “key” or something?)

Try writing this into the update script:

if(isKeyJustPressed("d")||isKeyJustPressed("left")){
inputD.gotoAndPlay(2);
}

Update: I figured out I need to put the code inside of the clip,
I put the code into the frame of the clip instead of the clip in the main scene,
it works now

1 Like