KeyframeReached

I was looking through a free models code, trying to understand each line and came across something I didn’t understand and didn’t even know existed.

Please can someone explain what the AnimationTrack:KeyframeReached does?

1 Like

There is an article on it AnimationTrack | Documentation - Roblox Creator Hub

1 Like

I read that and I still didn’t understand so I came here for a better understanding and possibly a better and more simpler explanation.

Basically, in the animation editor you can name keyframes and if the animation reaches that keyframe it will fire an event, this is useful for sounds in animations.

4 Likes

You can name individual keyframes inside an animation?

Yes you can.image

Thanks so much! This will definitely solve a lot of the problems I have been having with animations.

1 Like

Contrary to its name, the KeyframeReached event is actually a member of the AnimationTrack class. It exists so that you can connect an event to the moment that a playing animation reaches a certain Keyframe. (If you’re unfamiliar with the structure that goes into creating an animation, essentially an animation is a list of Keyframe which each have a Time property corresponding to when that keyframe should be played). KeyframeReached takes as an argument the name of the Keyframe you want a function to be triggered at. This could be useful if, for example, you wanted to play a sound at a specific time during an animation, or potentially wanted to perform some check at a point in an animation to determine whether its playback should be cancelled or allowed to continue (but these are just a few use cases).

1 Like