Localscript:
wait(1) local frame = script.Parent.Parent local disastertext = frame.disaster local ReplicatedStorage = game:GetService("ReplicatedStorage") local disaster = ReplicatedStorage.Remotes.returnPlayer disaster.OnClientEvent:Connect(function(s) disastertext.Text = table.concat(s, ',') print(s) frame.Visible = true wait(5) frame.Visible = false end)
Script that grabs each player and puts them in an array:
function getPlayers() for _,v in ipairs(game.Players:GetPlayers()) do table.insert(Array,v); print(Array) end end
I need to be able to get each players name and concat the table. Do I need to create another array that only contains the name of the player or do i need to completely rewrite how I am putting the players into the array?
I believe there may be a better option to this, and I am not fully sure if this is what you mean, but this is what I got:
You are wanting to store the Player object and the Player name in 1 table, you can do this by changing this to be something like this:
function getPlayers() for _,v in ipairs(game.Players:GetPlayers()) do local PlayerInfo = {} PlayerInfo.Player = v PlayerInfo.Name = v.Name table.insert(Array,PlayerInfo); print(Array) end end
What will this do? It will create a table called PlayerInfo and store that into Array for every player, [So a table inside a table.] PlayerInfo will have two values stored in it, The Player which will be = to the player object and Name which would be = to the Name off the player.
When you print array you should receive something like: {} This is the table Array, press on it to open it up. when you click on that you will get This table is the PlayerInfo Table. 1 = {} There will be one of those for each player, each player having its own index number. So it for 3 players it will be:
1 = {}
2 = {}
3 = {}
When you open up those lists for the PlayerInfo, you will get something like:
["Player"] = Object off player
["Name"] = Player Name
-- The outputs have been done by memory, I cant confirm if they are accurate