Tool ls glitching my game

hey so i made a knife, but for some reason it’s glitching my game. when i was testing it, it would duplicate a players tools after they were killed with it, and on the 5th or 4th test, the player wouldnt respawn after dying. the script and animation was made by me. the mesh wasn’t made by me. although i grabbed the mesh from the “Meshes” category in the toolbox so im assuming its harmless

heres the script

local tool = script.Parent
local cooldown = 2
local attackCooldown = false
local isCooldown = false
local player = script:FindFirstAncestorWhichIsA"Player" or game:GetService"Players":GetPlayerFromCharacter(script.Parent.Parent)

	local humanoid = script.Parent.Parent:WaitForChild("Humanoid")

	local animation = script.Parent:WaitForChild("Animation")

	local anim = script.Parent.Parent.Humanoid:LoadAnimation(animation)

	if not isCooldown then
		isCooldown = true
		humanoid.WalkSpeed = 5
		player.Character.Sprint.Disabled = true
		player.Character.Sprint.Disabled = false
		humanoid.WalkSpeed = 16
		isCooldown = false

		if touched.Name == "Head" and isCooldown then
			if not attackCooldown then
				attackCooldown = true
				touched.Parent.Humanoid.Health -= 30
				attackCooldown = false


feel free to ask any questions

It will help to show the errors generated in the output window. On first glance your script isn’t causing the errors you are mentioning, Let’s start with the errors that are coming up though.

If there aren’t any errors try using print() statements all around the script to show which places work or don’t work. Could also be used to see the debounce of a script. (How many times that print() statement runs).