AnimationTrack wont stop

Basically, I’ve made a script of idle, walk forward, backwards and sideways when you equip a tool.

tool.Equipped:Connect(function()
	equipped = true
	
	IdleTrack = Char.Humanoid:LoadAnimation(idle)
	IdleTrack:Play()
	IdleTrack.Priority = Enum.AnimationPriority.Core

	
	game:GetService("RunService").RenderStepped:Connect(function()
		local Speed = (Char.HumanoidRootPart.Velocity).Magnitude
		
		if not RunningForward and Speed > 0.50 and equipped and Char.Humanoid.MoveDirection.Z > 0 and _G.SHeld == false and _G.WHeld == true then
			Running = true
			RunningForward = true
			RunningBackward = false
			RunningSideways = false
			IdleTrack:Stop()
			if BackwardTrack then
				BackwardTrack:Stop()
			end
			ForwardTrack = Char.Humanoid:LoadAnimation(Forward)
			ForwardTrack:Play()
		elseif not RunningBackward and Speed > 0.50 and equipped and Char.Humanoid.MoveDirection.Z < 0 and _G.WHeld == false and _G.SHeld == true then
			Running = true
			RunningBackward = true
			RunningForward = false
			RunningSideways = false
			IdleTrack:Stop()
			if ForwardTrack then
				ForwardTrack:Stop()
			end
			BackwardTrack = Char.Humanoid:LoadAnimation(Backward)
			BackwardTrack:Play()
		elseif not RunningSideways and Speed > 0.50 and equipped and Char.Humanoid.MoveDirection.Z == 0  then
			Running = true
			RunningSideways = true
			RunningBackward = false
			RunningForward = false
			IdleTrack:Stop()
			if BackwardTrack then
				BackwardTrack:Stop()
			end
			ForwardTrack = Char.Humanoid:LoadAnimation(Forward)
			ForwardTrack:Play()
		elseif Running and Speed <= 0.50 and equipped then
			Running = false
			RunningBackward = false
			RunningForward = false
			RunningSideways = false

			if ForwardTrack then
				ForwardTrack:Stop()
			end
			if BackwardTrack then
				BackwardTrack:Stop()
			end

			IdleTrack:Play()

		end
	end)
end)

However, when I try to play the idle animation, the “ForwardTrack” just won’t stop and it keeps on topping the idle animation.

Video of the problem:


As you can see in the video, the animation keeps on playing if I stop.

Thank you for reading and possibly helping :slight_smile:

1 Like

I think it’s the problem of your animation, not sure if it is but try check if it’s looped or no.

It should be like this if it’s not looped:

looped:

I’m pretty sure that it’s not the problem as :Stop() should affect both looped and non-looped animations.

When I used the :Stop() with looped animation it was still exist till I fixed the animation. Try check it out and let me know.

Though either way, I need the animation itself to be looped as it’s a walking animation so… unlooping it would do more harm than good.

Make sure you have set the animation priority,

image

Edit: Check this before exporting