GetMarkerReachedSignal
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.
To learn more about using this function, see Animation Events in the articles/using animation editor|Using the Animation Editor
article.
More About Keyframes
Keyframe
names can be set in the Roblox articles/using animation editor|Animation Editor
when creating or editing an animation. They cannot, however, be set by a Script
on an existing animation prior to playing it.
Keyframe
names do not need to be unique. For example, if an Animation
has three keyframes named “EmitParticles,” the connected event returned by this function will fire each time one of these keyframes is reached.
See Also
AnimationTrack
, controls the playback of an animation on aHumanoid
orAnimationController
Keyframe
, holds thePose|Poses
applied to joints in aModel
at a given point of time in an animationKeyframe/AddMarker
Keyframe/RemoveMarker
Keyframe/GetMarkers
Parameters
Name | Type | Default | Description |
---|---|---|---|
|
The name of the |
Returns
Return Type | Summary |
---|---|
The signal created and fired when the animation reaches the created |
Code Samples
Listening to Keyframe Markers
This LocalScript
code waits for the local player’s Humanoid
object to load, then it creates a new Animation
instance with the proper Animation/AnimationId|AnimationId
. The animation is then loaded onto the humanoid, creating an AnimationTrack
, and the track is played with AnimationTrack/Play|AnimationTrack:Play()
. Following that, the AnimationTrack/GetMarkerReachedSignal|GetMarkerReachedSignal()
function detects when the “KickEnd” marker is hit.
local Players = game:GetService("Players") local player = Players.LocalPlayer local character = player.Character or player.Character:Wait() local humanoid = character:WaitForChild("Humanoid") -- Create new "Animation" instance local kickAnimation = Instance.new("Animation") -- Set its "AnimationId" to the corresponding animation asset ID kickAnimation.AnimationId = "rbxassetid://2515090838" -- Load animation onto the humanoid local kickAnimationTrack = humanoid:LoadAnimation(kickAnimation) -- Play animation track kickAnimationTrack:Play() -- If a named event was defined for the animation, connect it to "GetMarkerReachedSignal()" kickAnimationTrack:GetMarkerReachedSignal("KickEnd"):Connect(function(paramString) print(paramString) end)