I think that many people can be confused about this two terms,are there any differences between the two of them???
What are the differences?I would like to hear your thoughts
I think that many people can be confused about this two terms,are there any differences between the two of them???
What are the differences?I would like to hear your thoughts
GetPlayers gets every player under the player service
GetChildren gets every child of an instance
if u use it like game.players:getplayers() or game.players:getchildren() then its the same thing but it isnt recommended. but for other stuff getchildren gets the children of an instance, while get players just gets the players.
Players:GetPlayers()
is the recommended way of creating a table / list of every player currently in the game, as it is guaranteed to ONLY return Player
objects.
Players:GetChildren()
is NOT recommended, especially in the case that non-Player objects happen to be stored in the Players service for some reason. There is no guarantee that every object returned by Players:GetChildren()
would be a Player
object, since it would retrieve everything on the first layer of the service (such as BaseParts, Models, LocalScripts, etc.) without considering the object’s class.
Even if you don’t store objects in the Players service, it’s highly recommended to use Players:GetPlayers()
when wanting to refer to all the Players currently in the server with absolute certainty.
A lot of people are making this mistake,that why i created this topic