local players = game:GetService("Players") local children = players:GetChildren() wait(15) for i = 1, #children do print(children[i]) end
If a player leaves between the wait(15), will they still be printed as a child? Also, would "players" refer to "game.Players"?
Duplicate of question.
I will answer this instead.
If a player leaves between the wait(15), will they still be printed as a child?
Yes, but this can cause issues.
The player has left but you still have a reference to them in the table. Improperly handling this kind of stuff can result in a memory leak.
In the for loop you should be checking if the parent of the player is not nil. If it is, remove them from the table.
local Players = game:GetService("Players"); local children = Players:GetPlayers(); wait(15); for i = 1, #children do local client = children[i]; print(client and client.Parent and client.Name .. " is here" or "Removing client cuz left: " .. table.remove(children, i).Name); end
Btw use :GetPlayers() over :GetChildren().
Locked by User#24403
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?