So when a player dies with the tool equipped, and they respawn, then equip the tool then unequip it, the idle anim is still playing.
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 debounce = false local delayForDebounce = .5 tool.Equipped:Connect(function() local Equip = script.Parent.Parent.Humanoid:LoadAnimation(script.Sword) Equip:Play() wait(1.5) local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) idle:Play() end) tool.Activated:connect(function() if debounce == false then local choose = math.random(1,3) canattack.Value = true if choose == 1 then debounce = true local swing1animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch1) swingsound:Play() swing1animation:Play() wait(delayForDebounce) debounce = false elseif choose == 2 then debounce = true local swing2animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch2) swingsound:Play() swing2animation:Play() wait(delayForDebounce) debounce = false elseif choose == 3 then debounce = true local swing3animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch3) swingsound:Play() swing3animation:Play() wait(delayForDebounce) debounce = false end end end) tool.Deactivated:Connect(function() canattack.Value = true end) tool.Unequipped:Connect(function() local hum = char:WaitForChild("Humanoid") for i, v in pairs(hum:GetPlayingAnimationTracks()) do v:Stop() end end)
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 debounce = false local delayForDebounce = .5 tool.Equipped:Connect(function() local Equip = script.Parent.Parent.Humanoid:LoadAnimation(script.Sword) Equip:Play() wait(1.5) local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) idle:Play() end) tool.Activated:connect(function() if debounce == false then local choose = math.random(1,3) canattack.Value = true if choose == 1 then debounce = true local swing1animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch1) swingsound:Play() swing1animation:Play() wait(delayForDebounce) debounce = false elseif choose == 2 then debounce = true local swing2animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch2) swingsound:Play() swing2animation:Play() wait(delayForDebounce) debounce = false elseif choose == 3 then debounce = true local swing3animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch3) swingsound:Play() swing3animation:Play() wait(delayForDebounce) debounce = false end end end) tool.Deactivated:Connect(function() canattack.Value = true end) tool.Unequipped:Connect(function() script.Parent.idle:Stop() --im assuming its in the tool or what eve so ye end end)