Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to use table.concat on a table with players?

I want to use table.concat on a table filled with players, and I intended it to show the player's name but since it's a userdata it errors. How do I make the table.concat take the names of players from the table so it doesn't error?

1 answer

✓ Accepted answer

table.concat can only be used on a table of strings/numbers, so what you would have to do is get the names of the players into a table and then concat that table

local player_names = {}

for k, v in ipairs(game:GetService'Players':GetPlayers()) do
	table.insert(player_names, v.Name)
end

print(table.concat(player_names, ", "))

Hope this helped!

This discussion is preserved as it was. New answers, comments, and votes are closed.