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

How can I get this animation to play whenver the character starts walking?

I am trying to get this animation to play whenever the NPC moves, but it doesn't seem to work, what can I do?

local myHuman = script.Parent.Humanoid
local walkAnim = myHuman:LoadAnimation(script:WaitForChild("Run"))

if Humanoid.WalkSpeed > 0 then
	walkAnim:Play()
end

1 answer

✓ Accepted answer

What you need to do is rather than use WalkSpeed from the humanoid, you need to use an event called .Running.

Here is how it works.

local myHuman = script.Parent.Humanoid
local walkAnim = myHuman:LoadAnimation(script:WaitForChild("Run"))

myHuman.Running:Connect(function(speed)
	if speed > 2 then
		walkAnim:Play()
	end
end)

By using the .Running event, you can detect if the player is moving above a certain speed, and if it does, make the animation play.

1 comment

0

That was quick, thanks it works.

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