Pausing animation at the last frame is a problem

Hi so I wanted to make that it will pause the animation at the last frame. Before it worked well, but now it’s just going back to original position. I need to say that I was in Studio.

I was using task.wait with length… and AdjustSpeed:0.

Why is it happening that it’s going back to original position even though it’s used? Is that a bug? I didn’t touched a script when it worked.

1 Like

task.wait and wait are both amazing tools for this, unfortunately both may delay by a few milliseconds which may be late to stop the animation. That’s why it’s good practice to stop the animation RIGHT before it ends, like such:

task.wait(animation.Length * 0.95)
animaton:AdjustSpeed(0)

Although it wont quite finish the animation, it’s very close to it and there won’t be much difference at all between this and 0.05 more of its duration.

Note: This depends on the length of the animation, if you have a longer animation you may want to bump the .95 to a .97 or such.

2 Likes

To get better precision I would opt to use AnimationEvents. Just add an event a frame before the end of the animation and it should work.

YourAnimationTrack:GetMarkerReachedSignal("EventBeforeEndFrame"):Connect(function(paramString)
	YourAnimationTrack:AdjustSpeed(0)
    print("Should have stopped animation!")
end)
3 Likes

I will try that and I will notify if it will work. and also this upper.

1 Like