PlayerAdded (Event)
From Legacy Roblox Wiki
(Redirected from PlayerAdded)
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:
local Players = game:GetService("Players")
local function onPlayerAdded(player)
print("A player has entered: " .. player.Name)
end
Players.PlayerAdded:connect(onPlayerAdded)
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 ipairs(Players:GetPlayers()) do
onPlayerAdded(player)
end