When player respawns they dont get killed

Code:

image

need more information on what you are trying to accomplish

For some reason repeat doesn’t work in Server scripts. Just use a while loop or a heartbeat loop.

  • Problem: Players get a new humanoid when they spawn, so the Hum variable will only work if they don’t die.

  • Solution: Connect the killing function to the PlayerAdded and CharacterAdded events, so you can find their new humanoid every time they respawn.

local Kill = true -- In case you want to stop killing people
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        if kill == true then
            character.Humanoid.Health = 0 -- Kill them
        else
            repeat wait(2) until kill == true -- Wait until you want to kill
            character.Humanoid.Health = 0 -- Kill them
        end
    end)
end)

while loop didnt work either idk

Just use Humanoid.Died to check

Humanoid:TakeDamage() does not affect characters with ForceFields. Set the SpawnLocation’s Duration property to 0 so there’s no respawn forcefield.

1 Like

If you want to kill the player when it respawns, just use the Humanoid.Died event.

Like so:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
           local humanoid : Humanoid = character:WaitForChild(“Humanoid”)
          humanoid.Died:Connect(function()
            character:BreakJoints()
        end)
    end)
end)