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

Insert Player Names Into A Table?

local players = {""}

game.Players.PlayerAdded:connect(function(player)
local getPlayerNames = game.Players:GetPlayers().Name
table.insert(players, getPlayerNames)
wait(0.1)
print(table.concat(players, ", ")
end)

I am trying to make a table that holds the value of all of the player's names in the server, but the above code doesn't work. Can someone help me out?

2 comments

1

Line 4 is not necessary, all you need to do is change line 5 [table.insert(players,player.Name)].

0

ok thanks

1 answer

✓ Accepted answer

First off, let's address the issues:

  • You attempt to get the name of a table.
  • On line 1, you create the table with a string already in it, this will cause problems with your concatenation.

Let's fix those problems now.

local players = {};

game.Players.PlayerAdded:connect(function(player)
table.insert(players, player.Name);
wait(0.1);
print(table.concat(players, ", ");
end);

NOTE: The wiki is a great place to research anything you don't understand

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