CharacterAutoLoads: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Anaminus
Created page with "<onlyinclude>{{Property |name = CharacterAutoLoads |type = {{type|bool}} |description=Indicates whether Characters will respawn automatically. |object=Players }}</onlyincl..."
>Anaminus
No edit summary
Line 28: Line 28:
if Humanoid then
if Humanoid then
Humanoid.Died:connect(function()
Humanoid.Died:connect(function()
delay, then respawn the character
-- delay, then respawn the character
wait(respawnTime)
wait(respawnTime)
Player:LoadCharacter()
Player:LoadCharacter()
Line 35: Line 35:
end)
end)
Player:LoadCharacter(true) -- load the character for the first time
Player:LoadCharacter() -- load the character for the first time
end)
end)
</code>
</code>

Revision as of 21:37, 10 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)