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

How do you stop a walking animation when the player stops walking?

Asked by 6 years ago
Edited 6 years ago

I have tried for several months to make a successful walking animation. I have found out how to start the animation, but I don't know how to stop it when the player stopped walking.

--walking animation

--Variables

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.character

--Main

UIS.InputBegan:connect(function(inputObject)
    if inputObject.KeyCode == Enum.KeyCode then
       local animation = Instance.new("Animation")
       animation.AnimationId = "https://www.roblox.com/asset?Id=1238381932"
       local PlayAnim = char.Humanoid:LoadAnimation(animation)
       PlayAnim:Play()
    end
end)

then I used this to try and stop it.

player.Character.Humanoid.Running:connect(function(speed)
    local animation = Instance.new("Animation")
    animation.AnimationId = "https://www.roblox.com/asset?Id=1238381932"
    local player = game.Players.LocalPlayer
    local char = player.character
    PlayAnim = char.Humanoid:LoadAnimation(animation)
     if speed == 0 then
         PlayAnim:Stop()
     end
 end)

but, it does not work. I have tried before but failed. Can some one help me?

1 answer

Log in to vote
0
Answered by
ax_gold 360 Moderation Voter
6 years ago

Roblox likes to be stupid when it comes to walking animations. Try this script below. If It doesn't work, try changing '0' at line 7 to '1'. If it still doesn't work, let me know and we can try something else.

player.Character.Humanoid.Running:connect(function(speed)
    local animation = Instance.new("Animation")
    animation.AnimationId = "https://www.roblox.com/asset?Id=1238381932"
    local player = game.Players.LocalPlayer
        local char = player.character
        PlayAnim = char.Humanoid:LoadAnimation(animation)
    if speed > 0 then
        PlayAnim:Play()
    else
        PlayAnim:Stop()
    end
 end)
0
Sadly, the script does not work. But please still try and help me. Thanks for trying. billybobpumpkin 0 — 6y
0
Did the script show any errors? ax_gold 360 — 6y
0
No it did not. billybobpumpkin 0 — 6y
0
hm... add in "print(speed)" at line 2 and tell me if the speed ever says 0. ax_gold 360 — 6y
0
the out put says this: 0 (x5), 13.111275672913, 16, 2.8887257575989, 0 billybobpumpkin 0 — 6y
Ad

Answer this question