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?

5 comments
Sadly, the script does not work. But please still try and help me. Thanks for trying.
Did the script show any errors?
No it did not.
hm... add in "print(speed)" at line 2 and tell me if the speed ever says 0.
the out put says this: 0 (x5), 13.111275672913, 16, 2.8887257575989, 0