Getting Players

Is there a difference between game.Players:GetPlayers() and game.Players:GetChildren()?
I use :GetChildren() out of habit, but is there anything wrong with that? Should I switch over to :GetPlayers()?

4 Likes

As far as I know no. Just the difference is that Roblox knows it will be player instances so the Tab that shows you the properties and recommendations will match with :GetPlayers with the properties and events of a player instance. But this same effect can be made if you do this:

for I, v : Player in game.Players:GetChildren() do

end

—Vs..

for I, v in game.Players:GetPlayers() do

end

—Same thing just that with one of them Roblox knows it will be players automatically..

Only difference is if inserted objects are found in the Players, that aren’t players, which I don’t know if this is possible and I’m not sure why you would…

1 Like

according to documentation (Players | Documentation - Roblox Creator Hub), GetPlayers() functions the same way as GetChildren() except it ONLY returns Player objects.

3 Likes

It’s the same thing, the only difference is that if :GetPlayers() won’t return any non player instances inside Players.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.