The main difference is that :GetChildren() will return players in the game as well as players that are not in the game while :GetPlayers() only returns players that are still in the game. This is useful if you want to know how many players are in the game after someone leaves.
Some anti-cheat devs will throw things into the players service to throw off exploiters
Instance:GetChildren() is a function that nearly everything inherits. Players:GetPlayers() was written for cleanliness and possible edge-cases. In most cases, they would do the same thing, but you should use :GetPlayers() because it was specifically made for this scenario.
Why did you revive this? This has been settled for a long time… I didn’t see that the last post was over a year ago until I had already answered. Things archive for a reason.
There is a difference. If you are using game.Players:GetChildren()
in a script, it will return with all variables within Players. Hence why we use game.Players:GetPlayers
, because it will only return Player objects within Players. The only real time you should use game.Players:GetChildren()
is when you have a loop, otherwise never use it. This is because for loops go through every variable within the pairs
or ipairs
part of them.
i
= Index, or the order it is going in/ the current value.
v
= Variable, or which object the index is on.
The only time you should ever use game.Players:GetChildren()
is when you want EVERY child of the Players class. Otherwise, stick to game.Players:GetPlayers()
.
I discovered a new property of the method and decided to share it.