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", ...)
footstep:Play()
end
-- Load the animation and loop it
local animTrack = humanoid:LoadAnimation(anim)
animTrack.Looped = true
-- Connect the event
local onFootstep = animTrack:GetMarkerReachedSignal("FootStep")
onFootstep:Connect(onFootStep)
-- Finally, play the animation so the event fires!
animTrack:Play()