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

How do I insert player names into a table?

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 comment

1 answer

✓ Accepted answer
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, ", "))

2 comments

1

The correct method for table.insert is table.insert(table, value). Your script would error.

0

whoops

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