CharacterAutoLoads (Property): Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>JulienDethurens Created page with "<onlyinclude>{{Property |name = CharacterAutoLoads |type = {{type|bool}} |description=Indicates whether Characters will respawn automatically. |object=Players }}</onlyincl..." |
>Tenal categorizing |
||
(2 intermediate revisions by the same user not shown) | |||
Line 38: | Line 38: | ||
end) | end) | ||
}} | }} | ||
[[Category:Properties]] |
Latest revision as of 17:21, 13 April 2012
CharacterAutoLoads | |
Type | bool |
Description | Indicates whether Characters will respawn automatically. |
Member of | Players |
Remarks
If this is set to true, Players will get a character automatically when they join the game, as well as when they die. There is a 5 second delay between death and respawning.
If set to false, Characters wont load automatically, allowing you to respawn manually using LoadCharacter.
Example
This script turns off auto-loading and simulates character respawning.
local respawnTime = 5
local Players = Game:GetService("Players")
Players.CharacterAutoLoads = false
Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
-- find the humanoid, and detect when it dies
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
Humanoid.Died:connect(function()
-- delay, then respawn the character
wait(respawnTime)
Player:LoadCharacter()
end)
end
end)
Player:LoadCharacter() -- load the character for the first time
end)