I have been working on this kill script and it seems to kill me the FIRST time. After I respawn, my friend attempted to kill me again. But this time the kill script does not work. I tried debugging scripts and it lead nowhere, no errors, nothing.
ReplicatedStorage.KillHumanoid.OnServerEvent:Connect(function(player)
while wait(0.5) do
workspace[player.Name].Killpart.Touched:Connect(function(hit)
if debounce then return end
debounce = true
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid ~= nil then
local victim = game.Players[humanoid.Parent.Name]
if humanoid and humanoid ~= player.Character.Humanoid and victim.Team ~= game.Players[player.Name].Team then
humanoid.Health = 0
humanoid.Died:Connect(function()
if isDead then return end
isDead = true
game.Players[player.Name].leaderstats.Kills.Value += 1
end)
wait(0.5)
end
debounce = false
end
end)
end
end)