local debounce = false local debounce2 = false local toolNoning = humanoid:LoadAnimation(toolNoneAnim) function attack(hit) if hit and hit.Parent then local enemy = hit.Parent:FindFirstChild("Humanoid") if enemy then if enemy:IsA("Humanoid") and hit.Parent.Name ~= sp.Name then debounce = true while debounce do toolNoning:Play() print "wait" wait(3) torso.TouchEnded:connect(function(hit2) if hit2 == hit then debounce = false end end) end end else if hit.CanCollide then humanoid.Jump = true end end end end
Game tends to crash if many humanoid parts (such as a gun held by a humanoid with many parts) collide with it, but I'm fairly sure the debounce mechanism is supposed to stop that....
Creating a connection in a while loop will repeatedly generate the connection and they will not go away. This will crash your game. The connection should be made before the while loop, and disconnected when it's finished.
local debounce = false local debounce2 = false local toolNoning = humanoid:LoadAnimation(toolNoneAnim) function attack(hit) if hit and hit.Parent then local enemy = hit.Parent:FindFirstChild("Humanoid") if enemy then if enemy:IsA("Humanoid") and hit.Parent.Name ~= sp.Name then debounce = true local connection; connection=torso.TouchEnded:connect(function(hit2) if hit2 == hit then debounce = false connection:disconnect() end end) while debounce do toolNoning:Play() print "wait" wait(3) end end else if hit.CanCollide then humanoid.Jump = true end end end end