Wait for animation

I wont a line of code to play after an animation is done playing how do i do that with out using maybe waits.

for example

someAnimation:play

somefunction() -- want this to run after animation stops playing

I want an animation to play after another animation is the main goal tho

You can use Animation.TimeLength to wait until the animation is finished.

task.wait(MyAnimation.TimeLength)

i havent scripted in a few years what is task?

task.wait() is like wait(), but much better and more efficient.

1 Like

TimeLength doesnt like exist

i got an error saying its not a valid member

Hold on.I believe it is length. I prob was confused by sound’s TimeLength
Make sure you have your animation track.

1 Like

TimeLength is a property in animation that defines length of your animation play time

someAnimation:play()
someAnimation.Stopped:Wait()
somefunction()

check the animation track events, and use “Stopped” to get when the animation finishes.
https://developer.roblox.com/en-us/api-reference/class/AnimationTrack#events-1

2 Likes

It works! how would I make function play when an anim is over would i do it like this

anim:Play()
task.wait(anim.Length)	
someFunc()

You can either use Stopped or continue with that, but just call your function after the anim ended.

task.wait(anim.Length) will wait until your animation is finished.

thank you @gertkeno for the other solution

1 Like