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

How do I insert player names into a table?

Asked by 10 years ago
playing = {}
for i, v in pairs(game.Players:GetChildren()) do
    if v.Character then
        if v.Character:FindFirstChild("Ingame") then
            playing = {v.Name}
        end
    end
end

I need to know how to insert player's names into a table. Like in many survive disasters games(Not for one) they show all the surviving players names in a message. How would I make that except only the names in a table?

1 answer

Log in to vote
2
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago
local playing = {}
for i, v in pairs(game.Players:GetPlayers()) do
    if v.Character and v.Character:FindFirstChild("Ingame") then
         table.insert(playing, v.Name)
    end
end
print("Playing: "..table.concat(playing, ", "))

1
The correct method for table.insert is table.insert(table, value). Your script would error. Articulating 1335 — 10y
0
whoops Azarth 3141 — 10y
Ad

Answer this question