What's up with track.length?

I have a script where you play an animation track, it waits the tracks length then does something. However, when you first join the track plays and the length is literally 0, so it’s instant. It looks chopped, does anyone know how to fix this? I’m playing the track on the server because it needs to be on the server.

EDIT: So I also checked out preloadasync, and I made a script that preloads it on the client. This doesn’t change how it works on the server, AND the animation tends to fail preloading for some reason it never succeeds to preload.

You should use the GetMarkerReached signal event. Just mark the frames of actions inside of the animation editor.

AnimationTrack.Length returns 0 if the animation hasn’t loaded.

1 Like

That’s a whole event, I need a wait(track.Length) each time you click I can’t just use an event for that.

If you are playing the animation track, there is an event called .Stopped, which, you can use the method :Wait() on to wait until the animation track has stopped, which should wait until the animation track has stopped playing, exactly the length. Although, I’m not really sure if it has any delay, there’s probably a catch

Disregard the things above. If you’re trying to sync with keyframes or a certain time in an animation, you should do like what xKaihatsu said, or perhaps do things the OG way - KeyframeReached

2 Likes

You can still use GetMarkerReached just by adding GetMarkerReached:Wait(). What this does is wait until the marker is reached but just making it wait until the event is fired instead of creating a whole function.

Try using AnimationTrack.Stopped. It fires once the anim is over (which i’m guessing is what you’re going for), so you won’t have to do wait(AnimationTrack.Length).

2 Likes

Actually, why do you need it to be on the server?

If you still need a solution, try

repeat wait() until track.Length ~= 0