This function returns an
DataType/RBXScriptSignal|event similar to the
AnimationTrack/KeyframeReached event, except it only fires when a specified
KeyframeMarker has been hit in an
Animation|animation. The difference allows for greater control of when the event will fire.
This event allows a developer to run code at predefined points in an animation (set by
Keyframe names). This allows the default functionality of Roblox animations to be expanded upon by adding things such as
ParticleEmitter|ParticleEffects at different points in an animation.
To learn more about using this function, see Animation Events in the
articles/using animation editor|Using the Animation Editor article.
Using the Returned Event
The RBXScriptSignal (event) returned by this can be connected to another function. The connection creates a
DataType/RBXScriptConnection listener that executes the connected function every time the animation hits the specified KeyframeMarker until disconnected using Disconnect().
More about Keyframes
Keyframe names do not need to be unique. For example, if an Animation has three keyframes named “Particles” the connected event returned by this function will fire each time one of these keyframes is reached.
Keyframe names can be set in the Roblox Animation Editor when creating or editing an animation. They cannot however be set by a
Script on an existing animation prior to playing it.
AnimationTrack, controls the playback of an animation on a
Keyframe, holds the
Pose|Posesapplied to joints in a
Modelat a given point of time in an animation
The name of the
The signal created and fired when the animation reaches the created
Listening to KeyFrameMarkers
This code sample plays an animation on the local
Player/Character|Character and prints when a
Keyframe that has a
KeyframeMarker named “FootStep” is reached during playback of the
Animation|animation. It does this by using the
AnimationTrack/GetMarkerReachedSignal function, which returns an event. This event fires when a keyframe marker with a given name is reached during playback.
You can test this sample by pasting it into a Script within an R6 NPC (the animation won’t play properly on an R15/Rthro rig, but the event will still fire). You can download this test R6 rig with the included animation and this code sample.