PlayerAdded (Event): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>JulienDethurens
No edit summary
>JulienDethurens
STOP CAPITALIZING LINKS IN THE MIDDLE OF SENTENCES!
Line 15: Line 15:
</code>}}
</code>}}


{{EmphasisBox|'''Note''': This method does not work as expected in [[Solo mode]], because the player is created before scripts that connect to PlayerAdded run.  To fix this problem during solo add this to the end of a script:|red|dark=y}}
{{EmphasisBox|'''Note''': This method does not work as expected in [[solo mode]], because the player is created before scripts that connect to PlayerAdded run.  To fix this problem during solo add this to the end of a script:|red|dark=y}}


<code lua>
<code lua>

Revision as of 08:29, 28 January 2012

PlayerAdded ( Player player )
Description Fired after a player enters the game.
Member of: Players


Example

This code will print A player has entered: , followed by the player's name, everytime a player enters: game.Players.PlayerAdded:connect(function(player) print("A player has entered: " .. player.Name) end)


Note: This method does not work as expected in solo mode, because the player is created before scripts that connect to PlayerAdded run. To fix this problem during solo add this to the end of a script:

for _, player in pairs(game.Players:GetChildren()) do PlayerAdded(player) end

See Also