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
The following example plays an animation on the local
Player/Character|character and prints a value whenever a
Keyframe that has a
KeyframeMarker named “FootStep” gets hit in the
The example listens to when the KeyFrame is hit by connecting the function markerReached to the event returned by
AnimationTrack/GetKeyframeReachedSignal, which fires whenever the KeyFrameMarker named “FootStep” gets hit.
In order for this to work as expected, it should be placed in a
local player = game.Players:GetChildren() local character = game.Workspace:WaitForChild(player.Name) local humanoid = character:WaitForChild("Humanoid") local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://437855404" local animTrack = humanoid:LoadAnimation(anim) animTrack:GetKeyframeReachedSignal("FootStep"):Connect(function(value) print(value) end) animTrack:Play()