"Using Animations in Games" tutorial still uses KeyframeReached event rather than GetMarkerReachedSignal

I’ve been following the Developer Hub tutorial on setting up Roblox animations in game and I’ve been having issues with the example code they provide:

The KeyframeReached event never fires for my animation events that I set up, so I’ve spent the last couple of hours trying to figure out why. Then I find out that KeyframeReached is deprecated… Please fix this.

I’ve searched for similar topics but failed to find any relating to the Developer Hub tutorial page; if this is a repeated topic then please let me know. Thanks.


I’ve updated the code sample on the page; it should be visible within an hour. Turns out this sample had much more wrong with it than just a typo.

Here's the code sample
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local hrp = character:WaitForChild("HumanoidRootPart")
-- Create a simple walk animation with "FootStep" markers
-- Note: this particular animation only plays on R6 rigs!
local markerName = "FootStep"
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://4707265121"

-- Create a footstep sound
local footstep = Instance.new("Sound")
footstep.SoundId = "rbxassetid://131436155"
footstep.Parent = hrp
-- This function is called when the marker is reached
function onFootStep(...)
    print("FootStep", ...)

-- Load the animation and loop it
local animTrack = humanoid:LoadAnimation(anim)
animTrack.Looped = true

-- Connect the event
local onFootstep = animTrack:GetMarkerReachedSignal("FootStep")

-- Finally, play the animation so the event fires!

Here’s a sample model you can check out with the updated code sample

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.