i have a table of players and i want to list them like this:
Player1, Player2, Player3 and Player4
but i dont know how to do this
Can you give a little bit more detail about listing players? Do you mean printing them?
Here’s an example you can use to list them like this:
for i, v in pairs(table) do
print(v)
end
More about for loops: Introduction to Scripting | Roblox Creator Documentation
You could do:
table.concat(playersList, ", ")
If you want to display the winners in a round, then table.concat() would probably fit.
If you want something a bit simpler, try table.unpack(playersList).
It would end up something like this:
--Option 1
print(table.concat(playersList, ", ")) -- assuming playersList is the list of players
--Output would be "Player1, Player2, Player3" etc.
--Option 2
print(table.unpack(playersList))
--Output would be "Player1 Player2 Player3" etc.
I personally use table.unpack for debugging and table.concat for something the player would see.
Reference:
table (roblox.com)
2 Likes