Help making a script that kills the player when they spawn in

Hey! I need help making a script that kills the player when they spawn in.
I’ve done lots of research but I can’t find what I’m looking for.
The script must only apply to the person who is spawning not anyone else in the server.

Thanks!

Note: I am pretty new to scripting. :slight_smile:

(just use ProButaray’s Code)

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Wait()
	player.Character:WaitForChild("Humanoid").Health = 0
end)
1 Like

That won’t work bc it’ll infinite yield and character isn’t a child of player, it’s a property.

Oh, nvm. I saw it somewhere, I’ll fix my code

Using WaitForChild() on the character is ineffective. The server should wait until it gets the character of the player.

game.Players.PlayerAdded:Connect(function(player)

    repeat
	    wait()
    until player.Character

    local character = player.Character

    character:WaitForChild("Humanoid").Health = 0
end)

Or the script you fixed above is eligible either.

6 Likes

No, I tried mine and it didn’t work. Oh well. Yours works better anyway (+1 like, I’m out of likes for today lol)

1 Like

Thankyou for the fast responce!

1 Like