Difference between GetPlayers vs GetChildren?

I haven’t found any posts about this elsewhere, so I will ask it here. What exactly is the difference between GetPlayers() as opposed to GetChildren(). I know GetPlayers only returns player objects, whilst GetChildren returns all the children of a specified parent. However, in the case of using it under the service “Players”, there literally is no difference.

For example, I know a lot of people who did this…


compared to this…


What use does this have over the other, it’s applicable for other uses such as workspace or ect, but for players?

1 Like

GetPlayers only gets the players.

Nothing really, I could be wrong correct me if I am

Edit: It only gets Children with the ClassName Player

That is what I’m asking. Technically they both get players under the service “Players”, so what is the difference. As far as I know, the only thing that exists under is “Players” is literally players.

Both of those achieve the same thing. GetChildren gets everything inside the place where you want. GetPlayers only gets the Players. There are only player objects in game.Players so GetChildren will also get all the players.

Yeah, but why is there two identical functions that return the same thing?

They don’t return the same thing. GetChildren returns a table with everything in a specific location. GetPlayers returns a table with only players.


GetPlayers() returns player objects in the Player’s service while GetChildren() get’s everything, even non player objects in the Player’s service if found.

1 Like

There are non-Players object in the Player’s Service? What. In what case would you have non-player objects there. Just curious since I never use it.

1 Like

There aren’t. If there are, :GetChildren() will return them as well. I did mentioned ‘if found’.

for _, v in ipairs(game.Players:GetChildren()) do
	print(v) -- print everything inside the players service

for _, v in ipairs(game.Players:GetPlayers()) do
	print(v) -- will only print if a player object found

There should not be any non-player objects in the Player’s service.

Say a script parents something to Players, :GetChildren() will find that child. :GetPlayers() only gets the players, which means it will not find that specified child the script added to Players.

So both ways get any child of the service. I understand that one Gets player objects, whilst the other gets every child. Since they both get the same thing, is there any differences?

For example

--Players-- Get every child inside

--Players-- Gets all player objects inside

You can see that they both get players. There is no difference, except for checking whether or not player object exist or not. They both get the players regardless.

Player’s service will only have players, but by chance people can insert something inside the Players service. :GetChildren() will return everything inside it while :GetPlayers() will return only players.

Of course :GetChildren() will return the players because there are players inserted to the Player’s service, if there were for e.g a CFrame object, :GetChildren() will also return the CFrame object.

That’s also the reason why :GetPlayers() is better.

1 Like

Is there any reason why someone would insert objects into the service? I mean…

No, but people can. Player’s service isn’t a place for storing stuff but you never know if a person is going to insert or not.

1 Like

Thankyou everyone for clarifying this. I always use GetPlayers under the Player’s Service, instead of the other, obviously.

I just don’t see the use for getchildren over getplayers under the service. I understand the functions and what they get, but they both still return players under the service. Since, players should be the only thing to exist, regardless. As @ArrantNickel mentioned you can create objects to store under the player and get that using GetPlayers, but that’s really the only reason why. I don’t see any other uses.

And hardly anyone stores objects under the service.

GetPlayers only return all player inside player service.

While GetChildren return everything on player service, include instance, model, or etc.

By default they wouldn’t and shouldn’t be any instances, models or ect. You can see what I mean.