Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to stop animations?

Asked by
Rhuxus 25
9 years ago

I'm using a looping animation I made in animation editor

workspace.Player1.Humanoid:LoadAnimation(workspace.LobsterAnim):Play()

But when I try to stop it

workspace.Player1.Humanoid:LoadAnimation(workspace.LobsterAnim):Stop()

It keeps playing. I tried deleting the animation also and it still keeps playing.

How do I make it stop?

1 answer

Log in to vote
2
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

Every time you call LoadAnimation a new AnimationTrack is created. When you try to stop the animation, you call LoadAnimation a second time. This creates a new AnimationTrack separate from the one that's actually playing! Therefore, when you stop it, nothing happens.

Store a single AnimationTrack in a variable, then play it and stop it as you wish. In pseudo code it would look like this:

local animTrack = Humanoid:LoadAnimation(animation)
animTrack:Play()
wait(1)
animTrack:Stop()
Ad

Answer this question