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

Humanoid not detecting speed in custom character?

Hi, I'm making a custom model and I'm trying to animate with a walk cycle. I've got everything down except for the part where you call an the event in the humanoid, speed. Here's my script:

local Humanoid = script.Parent.Humanoid local animation = script.WalkAnim local animTrack = Humanoid:LoadAnimation(animation) local player = game.Players.LocalPlayer.Character

local Humanoid = script.Parent.Humanoid
local animation = script.WalkAnim
local animTrack = Humanoid:LoadAnimation(animation)
local player = game.Players.LocalPlayer.Character

 player.Humanoid.Running:connect(function(speed)
	while wait(0.5) do
		print(speed)
	end
	if speed > 0 then
	       print("Player is running")
		   animTrack:Play()
	   else
	       print("Player has stopped")
		   animTrack:Stop()
	   end
end)

I'm trying to make it so that when the character walks/its speed is greater than 0, it plays the walk cycle. I tried this in play mode, but it prints "Player has stopped" but never "Player is running" when I walk, I added the print(speed) to see what was happening and it's always printing 0, no matter what move I make. Any help? Thanks in advanc

2 comments

0

I think your while loop is preventing the rest of your code from running. Try commenting it out.

0

Still doesn't work with leaving it out.

1 answer

local Humanoid = script.Parent.Humanoid local animation = script.WalkAnim local animTrack = Humanoid:LoadAnimation(animation) local player = game.Players.LocalPlayer.Character

player.Humanoid.Running:connect(function(speed) while wait(0.5) do print(speed) if speed > 0 then print("Player is running") animTrack:Play() else print("Player has stopped") animTrack:Stop() end end

end)

-- That is what you need?

2 comments

0

Code Block please!

0

Not really, I'm trying to get the script to detect when my character is walking. It always outputs 0, despite movement even with your script. Thanks though

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