Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this line of code not work? I am trying to die when I spawn.

My goal is so when I spawn I die instantly.

local plr = game.Players.LocalPlayer
local Char = plr.Character
local Humanoid = Char.Humanoid

function yes()
	Humanoid.Health = 0
end

yes()

1 answer

✓ Accepted answer

If you want the player to respawn instantly upon joining the game, then just put this code inside of a server script inside of workspace:

game.Players.PlayerAdded:connect(function(plr) --Player Added to the game
	repeat wait() until plr.Character --Wait for our player to show up
	local char = plr.Character
	char:BreakJoints() --Reset the Player
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.