How to freeze an animation at a certain timeposition

Right now, I’m trying to freeze an animation after it stops. I have used the stop function before, in which I wrote it like this:


But for some reason, this does not always work and sometimes it just directly continues the animation. I’m currently trying to use a different method which involves freezing an animation at a certain timeposition. My script looks like this:

	if animation.TimePosition == 0.417 then

And yeah, the script above isn’t working. I have taken a look at other posts of similar things including the roblox article about timepositions, but I didn’t really understand clearly about how they used timeposition to freeze an animation. I heard that there are also other ways like using keyframe reached, but currently I’m using Moon Animator instead of the default animation editor so I don’t know if they can still be used.

You could try:

if animation.TimePosition <= 0.417 then

(Unsure if it will work though)

You would have to constantly be checking in a loop if the TimePosition is equal to 0.417, which is an extremely precise number, and the loop might miss it. For example, a normal “while task.wait() do” loop runs about 30 times a second (if i remember correctly)

The loop might see the TimePosition as 0.415, then it would wait 1/30th of a second, and then the TimePosition would be 0.419. This could be your issue. What you could do is something like

repeat task.wait() until TimePosition >= 0.417

Thanks for the info, but the script didn’t do any freezing and it canceled out the script below it.

Try using GetMarkerReachedSignal Instead

I agree, this or ‘KeyframeReached’ (which is used to freeze animations in the default ‘Animate’ script) would be the preferred approach.