Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
BuDeep 214 Moderation Voter
4 years ago

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)
Ad

Answer this question