Hi, I saw this script in a book. Nothing was wrong with it except one thing didn't seem right. The author referenced players as:
local Players = game.Players:GetChildren()
when usually it is:
local Players = game.Players:GetPlayers()
I'm not sure whether it was best to use the first or second option.
Please help!
While both usually end generating the same array, they are two different things. GetChildren
returns everything that's parented to that object, in this case, Players
, whether it be a player or something else, while GetPlayers
only returns players and nothing else.
Use GetPlayers
if you purely want the players, and GetChildren
if you only want all its children.
https://developer.roblox.com/api-reference/function/Players/GetPlayers