Help With Animations

Currently, I have a tool that changes the default animations whenever you equip it, however, if are running and then you equip the tool, it makes the player run with no animations, however, if I stop and then run again the animation then plays. How could I fix this?

This is my current script

local function animationchanger()
	
	local humanoid = character:WaitForChild("Humanoid")

	for _, playingTracks in pairs(humanoid:GetPlayingAnimationTracks()) do
		playingTracks:Stop(0)
	end

	local animateScript = character:WaitForChild("Animate")
	animateScript.idle.Animation1.AnimationId = "rbxassetid://5955237072"
	animateScript.idle.Animation2.AnimationId = "rbxassetid://5955237072"
	animateScript.run.RunAnim.AnimationId = "rbxassetid://5955157531"
end

script.Parent.Equipped:Connect(function()
       animationchanger()
end

Try to check if character is currently running. If so play the run animation.

I’m guessing this is occurring because you are stopping all animations in your for loop but not playing any after. What you need to do is right after you set the animationId’s, have an if statement that detects whether the player is moving or not. After play the desired animation (run animation if moving or idle if not moving, etc) once you’ve set the new animation ID’s.