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

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

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

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)

5 comments

0

Sadly, the script does not work. But please still try and help me. Thanks for trying.

0

Did the script show any errors?

0

No it did not.

0

hm... add in "print(speed)" at line 2 and tell me if the speed ever says 0.

0

the out put says this: 0 (x5), 13.111275672913, 16, 2.8887257575989, 0

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