PlayerAdded (Event)
From Legacy Roblox Wiki
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