Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to use KeyframeReached with exported animations?

A person named XAXA told me this, Name your keyframes in the animationeditor after exporting them and replace the default animations with the new ones you created

*And then, * (This was an example)

AnimationTrach:KeyFrameReached:connect(function(name) if name == "blah" then -- steps end end)

Ok, I tried doing this but I didn't have great luck with it, I don't hear the sound play.

the parent of this script is an animation. Please note that this animation replaces the default roblox animation of the player character

local player = game.Players.LocalPlayer
local character = game.Workspace:WaitForChild(player.Name)
local humanoid = character:WaitForChild("Humanoid")
local sound = script:WaitForChild("FootstepSound")
local AnimationTrack =  humanoid:LoadAnimation(script.Parent)
AnimationTrack.KeyframeReached:Connect(function(name)
if name == "FootStep1" then  
sound:Play()
end 
end)


AnimationTrack.KeyframeReached:Connect(function(name)
if name == "FootStep2" then  
sound:Play()
end 
end)

1 answer

KeyframeReached should be an event and written as follow:

AnimationTrack.KeyframeReached

rather than

AnimationTrack:KeframeReached

1 comment

0

That fixed the output error before thank you, but for some reason the footstep sound doesn't play

This discussion is preserved as it was. New answers, comments, and votes are closed.