How to stop walking animation?

i have a character and i have figured out how to make a walking animation!
i used this to determine if the character started walking:

humanoid.Running:Connect(function(speed)
	if speed > 0 then
		humanoid:LoadAnimation(WalkingAnimation):Play()
	end
end)

and it works!
but uhhh… now it never stops :frowning:
and i have tried to just say that if it is 0 stop the animation but as i expected it also didn’t work…

so how to stop this animation after it has been played?

thanks in advance!

I would recommend storing the AnimationTrack in a Variable, because all this will do is Load a new anination everytime something happens, so like this:

local walkAnim = Hum:LoadAnimation(Anim)

-- In Event
if speed > amount then
    walkAnim:Play()
else
    walkAnim:Stop()
end

If you dont want the Track to loop, there is a property to stop this for the AnimationTrack

the walking animation still keeps playing and i don’t know how to stop it :frowning:

try that:

local animation = humanoid:LoadAnimation(WalkingAnimation)

humanoid.StateChanged:Connect(function(state,newstate)
	if newstate == Enum.HumanoidStateType.Running then
		animation:Play()
	else
		animation:Stop()
	end
end)

well i technically didn’t solve this problem , but i kinda changed it to not stand out that much…
like it’s still there but it looks like it isn’t…
so what i did is i made the animation play when the running event fired and made it stop when the npc would stop following the player…
so the problem is still there since it never stops when the npc actually stops… it stops when the npc loses the player and i assume he’s going to be idle…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.