Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Humanoid not detecting speed in custom character?

Asked by
wer8888 -7
7 years ago

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

0
I think your while loop is preventing the rest of your code from running. Try commenting it out. AZDev 590 — 7y
0
Still doesn't work with leaving it out. wer8888 -7 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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?

0
Code Block please! Vingam_Securis 213 — 7y
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 wer8888 -7 — 7y
Ad

Answer this question