Use the GetChildren or GetPlayers() method to create a table of the given instance's children. For your case:
local players = game.Players:GetChildren()
From here, if you want to turn this array from an array of player objects to an array of player names (strings) you could map over each value using the following function:
local function map(t, f)
local nt = {}
for i = 1, #t do
nt[i] = f(t[i])
end
return nt
end
And your final result would be:
local playerNames = map(game.Players:GetChildren(), function(field)
return field.Name
end)
You could also just individually access a players name when needed like players[i].Name.
1 comment
That's a bit extra, don't you think? And please use more descriptive variables