Welcome to the Forums!
Join thousands of other Roblox members with a free account.
Create Forum Account

[ANSWER] How to change the speed of respawning and more

  • This website was created by Roblox members to replace the official forums (because Roblox shut them down) Join us if you like Roblox!
Status
Not open for further replies.

FighterRBX

VIP
Reputation: 1 / 0 / 0
Dec 12, 2017
651
2
45
28
19
frustration
Roblox
Fighter169mobile
Discord
Fighter169mobile#2189
1) Make sure this property is off:

game.Players.CharacterAutoLoads = false

(or game >> Players >> CharacterAutoLoads: Uncheck it)

This makes it so the player doesn't load or respawn automatically.

2) Now we need to get the player from a non local script:

game.Players.PlayerAdded:Connect(function(player)
print(player .. " has joined!")
end

3) Now you should use the CharacterAdded event from the player instance. This event fires when the player in workspace is loaded ..and when the player respawns!

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(wPlayer) -- It returns the player in workspace

end)
end

4) Now time for spawning the player. To do this you use ":LoadCharacter()" on the player in game.Players

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(wPlayer)

end)
player:LoadCharacter()
end

5) The final thing to do is to add a .Died event on the player in workspace and then respawn/load the character whenever you decide to.

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(wPlayer)
wPlayer.Died:Connect(function()
wait(2) -- the delay until respawn
player:LoadCharacter()
end)
player:LoadCharacter()
end

Hope this helps. :) Feel free to ask any questions.
 
Status
Not open for further replies.