I always have this problem and sorry if I reposted this (I'm impatient).
problem: idle animation for punching tool stops (its looped) when I walk or jump. punching animations stop sometimes when the character idle animation (not the punching tool idle) plays.
code: ```lua 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) ```