Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you wait the length of an Animation?

I'd like to know how this is done, because I'm not entirely sure how to do this. I know with Sounds you can do:

local Sound = Instance.new("Sound")
wait(Sound.TimeLength)

1 answer

you can do this with the AnimationTrack.Stopped event

AnimationTracks are the objects returned by Humanoid:LoadAnimation or AnimationController:LoadAnimation

so, to wait for the animation to fniish playing, you can do this

local animation = path.to.Animation
local animationTrack = Humanoid:LoadAnimation(animation)

-- somewhere else in your script...
animationTrack:Play()
animationTrack.Stopped:Wait() -- wait for the Stopped event to fire
print("animation stopped")

alternatively, you could just wait out the length of the animation

animationTrack:Play()
wait(animationTrack.Length)
print("animation stopped")

This discussion is preserved as it was. New answers, comments, and votes are closed.