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

How to detect when a animation is finished playing?

Asked by
hellmatic 1523 Moderation Voter
7 years ago

How can I detect if a animation is finished playing?

1
print(AnimationTrack.Length) awesomeipod 607 — 7y

3 answers

Log in to vote
1
Answered by 7 years ago

Or to add on the above answer, you can wait until it is done playing in the same block of code.

1local animationTrack = humanoid:LoadAnimation(animationInstance)
2animationTrack:Play()
3wait(animationTrack.Length)
4--finished playing
Ad
Log in to vote
1
Answered by
hellmatic 1523 Moderation Voter
7 years ago

repeat wait() until not animationTrack.IsPlaying

Log in to vote
0
Answered by 7 years ago

If you have the animation track stored in a variable, you can use its Stopped event.

1myAnimTrack.Stopped:Connect(function()
2    -- do things
3end)

Answer this question