CharacterAutoLoads: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Anaminus
No edit summary
>JulienDethurens
Redirected page to CharacterAutoLoads (Property)
Line 1: Line 1:
<onlyinclude>{{Property
#redirect [[CharacterAutoLoads (Property)]]
|name = CharacterAutoLoads
|type = {{type|bool}}
|description=Indicates whether [[Character]]s will respawn automatically.
|object=Players
}}</onlyinclude>
 
{{clear floats}}
 
==Remarks==
If this is set to {{true}}, [[Player]]s 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.
 
<code lua>
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)
</code>

Revision as of 21:39, 10 April 2012