THIS IS NOT THE ENTIRE SCRIPT, IF YOU WISH TO SEE THE ENTIRE SCRIPT TELL ME AND I WILL UPDATE IT

Pretty much, I want a taser to drop in place of the sheriff's HumanoidRootPart when they die. One problem, when cloning the taser, it clones it roughly 10-20 times (often more) even though I added a debounce inside the function for when it's ran. The second problem, whenever I check for when a player dies to run the "HandleSheriff" function, it kills the sheriff when the bloxxer dies. I have absolutely no idea why this happens and I'm probably overlooking something. Last problem, the touched function inside the "DropNetgun" function doesn't fire when the pickup is touched.

I have no errors at all, and like I said whatever I try doesn't seem to work. If you could help me that would be awesome and my game would be one step closer to the outline being finished.

function handlesheriff(bloxxedplayer, character)
	local humanoid = character:FindFirstChild("Humanoid")
	
	if humanoid then
		local backpack = bloxxedplayer:FindFirstChild("Backpack")
		local root = character:FindFirstChild("HumanoidRootPart")
			
		if backpack and root then
			humanoid:UnequipTools()
			backpack:ClearAllChildren()	
			
			dropnetgun(root.Position)
		end
	end
	
	if bloxxedplayer ~= lastbloxxer then
		local wrongdoer = sheriff
							
		if wrongdoer and wrongdoer.Character then
			local wrongdoerhumanoid = wrongdoer.Character:FindFirstChild("Humanoid")
							
			if wrongdoerhumanoid then
				wrongdoerhumanoid.Health = 0
			end
		end
	end
end

local given = false

function dropnetgun(position)
	if not given then
		given = true
		
		local pickup = serverstorage:WaitForChild("Taser"):WaitForChild("Handle"):Clone()
		pickup.Name = "Pickup"
		pickup.Anchored = true
		pickup.CanCollide = false
		pickup.CFrame = CFrame.new(position)
		pickup.Parent = workspace
				
		local sparkles = Instance.new("Sparkles")
		sparkles.SparkleColor = Color3.new(0, 0.5, 1)
		sparkles.Parent = pickup
				
		pickup.Touched:Connect(function(hit)
			if hit.Parent then
				local humanoid = hit.Parent:FindFirstChild("Humanoid")
				
				if humanoid and humanoid.Health > 0 then
					local player = players:GetPlayerFromCharacter(hit.Parent)
					local taser = serverstorage:WaitForChild("Taser"):Clone()
							
					if player and player ~= bloxxer then
						local backpack = player:FindFirstChild("Backpack")
								
						if backpack then
							given = false
							
							pickup:Destroy()
							taser.Parent = backpack
									
							sheriff = player
						end
					end
				end
			end
		end)
		
		debris:AddItem(pickup, localroundtimer)
	end
end

function killsheriff(player)						
	if player and player.Character then
		local humanoid = player.Character:FindFirstChild("Humanoid")
		local root = player.Character:FindFirstChild("HumanoidRootPart")
							
		if humanoid then
			humanoid.Health = 0
			dropnetgun(root.Position)
		end
	end
end

while wait(6) do
	localroundtimer = roundtime
	
	while localroundtimer > 0 do
		localroundtimer = localroundtimer - 1
		textupdate.Value = "Game in progress..."
		
		activecontestants = {}
		bloxxeractive = false
		
		for _, player in pairs(contestants) do
			if player and player.Character then
				local humanoid = player.Character:FindFirstChild("Humanoid")
				local isplaying = player.Character:FindFirstChild("IsPlaying")
				
				if humanoid and humanoid.Health > 0 and isplaying then
					table.insert(activecontestants, player)
					
					player:WaitForChild("PlayerGui").TextGui.Enabled = false
					
					humanoid.HealthDisplayDistance = 0
					humanoid.NameDisplayDistance = 0
					
					if player == bloxxer then
						bloxxeractive = true
					end
				end
				
				player.Character:FindFirstChild("Humanoid").Died:Connect(function()
					if player == sheriff then
						handlesheriff(player, player.Character)
					elseif player ~= sheriff and bloxxeractive then
						killsheriff(sheriff)
					end
				end)
			end
		end
		
		
		if #activecontestants <= 1 or not bloxxeractive then
			break
		end
		
		wait(1)
	end
end