Wait for PlayerAdded

  1. What do you want to achieve?

so i want to make a player list by using a PlayerAdded event .

  1. What is the issue?

because player will load faster than the PlayerAdded event script , so i was thinking is there a way to slow down and make the PlayerAdded event detect the player join ??

you can make a table and insert the player in the table everytime a player joins.
like this:

local players = {}
game.Players.PlayerAdded:Connect(function(plr)
    players[#players+1] = plr.Name
end)

or you can update your list everytime a player joins like this:

local players = {}
game.Players.PlayerAdded:Connect(function()
    players = game.Players:GetPlayers()
end)

If this helps, I will really appreciate if you mark this as a solution

1 Like

Here is what I would do.

local Players = game:GetService("Players")
local function UpdatePlayerList()
    local players = Players:GetPlayers()
    -- Update UI or what ever you need to do
end
UpdatePlayerList()
Players.PlayerAdded:Connect(UpdatePlayerList)
1 Like