I'm new at coding, I know very little on how to code but I have been able to create some simple scripts (walkspeed, map changing, instant respawn) so far. However I'm having trouble finding info on how to make a player respawn automatically every _ seconds. I need to do this because in the midst of map changing the player falls into the void and dies. Thanks!
COMMUNITY QUESTION
How would I make a script that makes a player respawn every _ seconds?
3 answers
Use a loop (http://wiki.roblox.com/index.php?title=Loops) Here's an example.
while wait(5) do
game.Players.Player1:LoadCharacter()
end
local player = "mamaluigi1234" -- Change to the name of the player
local seconds = 60 -- Change to how many seconds between respawns
while true do
wait(seconds)
if game.Players[player] then
game.Players[player]:LoadCharacter()
end
end
1 comment
0
if game.Players[player] would error if the player left the game.
game.Players.PlayerAdded:Connect(function(player)
while wait(5) do -- changed 5 to whatever time you need
player:LoadCharacter()
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Alternatively instead of respawning them constantly, you can teleport them to a game lobby or respawn them in one until the new map loads.