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)
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)
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.