How can i stop my tool idle animation?

I want to stop my idle animation whenever player unequipped the tool but i can’t make it.

local WeaponTool = script.Parent.Parent.Parent

local randomSlash = 1

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")

local EquipAnim = humanoid:LoadAnimation(script:WaitForChild("Equip"))
local IdleAnim = humanoid:LoadAnimation(script:WaitForChild("Idle"))
local Attack1Anim = humanoid:LoadAnimation(script:WaitForChild("Attack1"))
local Attack2Anim = humanoid:LoadAnimation(script:WaitForChild("Attack2"))

WeaponTool.Equipped:Connect(function()
	game.ReplicatedStorage.ConnectM6D:FireServer(WeaponTool.PathmakerModel.BodyAttach)

	char.Torso.ToolGrip.Part0 = char.Torso
	char.Torso.ToolGrip.Part1 = WeaponTool.PathmakerModel.BodyAttach

		script.Value.Value = true
	if script.Value.Value  == true then
		EquipAnim:Play()
		wait(0.5)
		while true do
			wait(0.01)
			IdleAnim:Play()
		if	script.Parent.Parent.Parent.Unequipped then
				IdleAnim:Stop() --Idle Anim here
			break
			end
		
			
		end
	
		end
	
	
end)

You need to connect event for .Unequipped:

WeaponTool.Unequipped:Connect(function()
IdleAnim:Stop()
end)
1 Like

It not works i allready tryed this

1 Like

You wrote it like this and put it inside your .Equipped event that’s why it doesn’t work.
image

try just local IdleAnim . if idle just do EquipAnim = Humanoid:LoadAnimation(script:WaitForChild(“Idle”))
and IdleAnim:Play() --to play and idleAnim:Stop() to stop

	while true do
			wait(0.01)
			IdleAnim:Play()

			WeaponTool.Unequipped:Connect(function()
			
				IdleAnim:Stop()
		
			end)

		end

Like that?

1 Like

No… why are you wrapping it in a loop?

if you make a loop,it wont do code below loop till its done (Never)

Okay i changed that.
image

Thank you so much bro it worked! :upside_down_face:

1 Like

Set it as solution :smiley: im happy u found your way thru it

1 Like