CharacterAdded (Event): Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>GoldenUrg initial - from experience |
>GoldenUrg reformat; added example |
||
Line 1: | Line 1: | ||
<onlyinclude> | {| | ||
{{Event| | |<onlyinclude>{{Event| | ||
name = CharacterAdded | name = CharacterAdded | ||
|arguments = [[Instance]] ''character'' | |arguments = [[Instance]] ''character'' | ||
|description = Fired when a character spawns or respawns. | |description = Fired when a character spawns or respawns. | ||
|object = [[RBX.lua.Player (Object)|Player]] | |object = [[RBX.lua.Player (Object)|Player]] | ||
|}} | |}}</onlyinclude> | ||
</onlyinclude> | |} | ||
== Description == | |||
The ''character'' will be a model with Humanoid, all body parts, scripts, and joints. The model will be completely loaded when triggered by game. | The ''character'' will be a model with Humanoid, all body parts, scripts, and joints. The model will be completely loaded when triggered by game. | ||
== Usage == | |||
<pre> | |||
function onRespawn(character) | |||
-- do something with character/backpack/etc. | |||
end | |||
function onPlayerEntered(newPlayer) | |||
newPlayer.CharacterAdded:connect(onRespawn) | |||
end | |||
game.Players.PlayerAdded:connect(onPlayerEntered) | |||
</pre> |
Revision as of 01:27, 20 May 2010
|
Description
The character will be a model with Humanoid, all body parts, scripts, and joints. The model will be completely loaded when triggered by game.
Usage
function onRespawn(character) -- do something with character/backpack/etc. end function onPlayerEntered(newPlayer) newPlayer.CharacterAdded:connect(onRespawn) end game.Players.PlayerAdded:connect(onPlayerEntered)