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

How do I make a table inside a table?

Is there a way to not repeat

local arg = {} local arg2 = {} local arg3 = {} ... ...

?

local set = {}
local arg = {}
local arg2 = {}
local arg3 = {}
local num = 0
msg = msg:sub(#ms.StartCommand+1):lower()
for w in msg:gmatch("%S+") do
    num = num + 1
	for a in w:gmatch("([^,]+)") do
    if num == 1 then
	    table.insert(arg,#arg+1,a)
    elseif num == 2 then
	    table.insert(arg2,#arg2+1,a)
    elseif num == 3 then
	    table.insert(arg3,#arg3+1,a)
    end
end

1 comment

0
local Table = {
{}
}

1 answer

If you want to make a table inside of a table when it is defined, try this.

local table1 = {
	table2 = {},
}

If you want to insert a table inside another table after it has been defined, try this.

local table1 = {}
local table2 = {}
table.insert(table1, table2) -- 'table' is a reserved name

Tables can hold almost any value... including more tables.

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