Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I list every player into a table?

Asked by 8 years ago

I know how to do insert table but I dont know how to get a list of the players can someone help?

Heres my script so far:

local players = {}

2 answers

Log in to vote
1
Answered by
Yirny 30
8 years ago

Use a for loop

local players = {}
for i,v in pairs(game.Players:GetChildren()) do --where i is the index and v is the value
    table.insert(players,v.Name) --v is each player in the game so .name is their name
end
0
thank you so much i didnt even know you could do that. :D Exacerbatory 10 — 8y
Ad
Log in to vote
3
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
8 years ago

game.Players:GetPlayers() returns a list of all of the players currently in the game.

Answer this question