Is there a difference between game.Players:GetChildren() and game.Players:GetPlayers()?

When I code I usually will use game.Players:GetChildren() but I was wondering if I should use :GetPlayers() instead? Is there a difference between the two? If so, what are they?

Yes, :GetChildren returns an array of everything inside (parent of game.Players).
:GetPlayers returns an array of every player in the game (the player instance).

https://developer.roblox.com/en-us/api-reference/function/Players/GetPlayers

1 Like

The only thing that will be in Players are players. Am I correct?

Canonically, you would use GetPlayers instead of GetChildren for some readability improvement. Also somehow allows debugging faster if you know when GetPlayers is called by searching for the term.

Also it does make a difference in case random instances somehow appear in the Players service.

1 Like

That’s usually the case, however it depends if people want to put stuff there or not.
Generally go with GetPlayers as it’s meant for players.

Is that even a word??? If it is, I’m impressed lol.

Canonically - definition of canonically by The Free Dictionary.

1 Like