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

How do you make the respawn faster?

Asked by 8 years ago

Do you know how to make the respawn faster?

3 answers

Log in to vote
1
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
8 years ago

To do this, you will need to disable automatic respawning. This is easily done by setting the property of the Players service CharacterAutoLoads to false.

After that you need to write a function that will handle character respawning for each player that enters the game. We can use the PlayerAdded event to get each player. To actually load the character, we can use the function of player LoadCharacter. Using the Died event of humanoid we can detect when the player needs to be respawned. This event should be connected each time the player spawns so we will have to use the CharacterAdded event. When the Died event fires, we will simply wait a specific amount of time and call the LoadCharacter function again.

local respawnDelay = 5

game.Players.CharacterAutoLoads = false

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        local humanoid = character:FindFirstChild("Humanoid")
        if humanoid then
            humanoid.Died:connect(function()
                wait(respawnDelay)
                player:LoadCharacter()
            end)
        end
    end)
    player:LoadCharacter()
end)
0
Thanks User#13091 0 — 8y
0
You're welcome :) BlackJPI 2658 — 8y
0
I accept your answer User#13091 0 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

You can use LoadCharacter, a method which can be used on the player from a serverscript to respawn the player.

If you pair this with the Died event of a humanoid, then you can change the respawn time.

Article on LoadCharacter

and

Article on DiedEvent

0
Thanks User#13091 0 — 8y
Log in to vote
0
Answered by 5 years ago

There is now a Players.RespawnTime property, so now you don't need a script to do this. Just go in the Explorer, select the Players service and set the RespawnTime property to how many seconds you want in the Properties menu.

Answer this question