So this wasn't answered after 4 days and it isn't on the front page so I decided to repost it since the people who tried to answer the question abandoned me.
Problem: The idle animation after death and unequipped does not stop.
Code:
local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:wait() local tool = script.Parent local swingsound = tool:WaitForChild("Swing") local canattack = tool:WaitForChild("CanAttack") local deb = false local cooldown = 1.3 tool.Equipped:connect(function() local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) idle:Play() end) tool.Activated:connect(function() if deb == true then return end deb = true local choose = math.random(1,2) canattack.Value = true if choose == 1 then local swing1animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch1) swingsound:Play() swing1animation:Play() wait(cooldown) deb = false elseif choose == 2 then local swing2animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch2) swingsound:Play() swing2animation:Play() wait(cooldown) deb = false end end) tool.Deactivated:connect(function() canattack.Value = false end) tool.Unequipped:connect(function() local hum = char:WaitForChild("Humanoid") for _,anim in pairs(hum:GetPlayingAnimationTracks()) do anim:Stop() end end)