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

Instantly re-spawn on death?

Asked by 7 years ago

How can one make players instantly re-spawn on death?

1
Just a note, but if you instantly respawn you won't even "seem" to die. The reason why most games don't do this is they'll just "teleport" to spawn like nothing happened. Tomstah 401 — 7y

2 answers

Log in to vote
1
Answered by
Jellyfosh 125
7 years ago

Using the Died event of humanoid and the LoadCharacter event of Player. You could do something like this:

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        local humanoid  = character:WaitForChild("Humanoid")
        humanoid.Died:connect(function()
            player:LoadCharacter()
        end)
    end)
end)
Ad
Log in to vote
1
Answered by 7 years ago

You can use LoadCharacter to force a player to spawn. If you run this function when the player dies there should be little to no delay in spawn time.

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(charModel)
        local hum = charModel:WaitForChild('Humanoid', 5) -- should make it safer
        if hum then
            hum.Died:Connect(function()
                plr:LoadCharacter() -- force a player to spawn ie no delay
            end)
        end
    end)
end)

I hope this helps.

Answer this question