How would I insert this table into a table

Quick question, how exactly would I insert the table below inside of an existing table?

[1] = {
        [player1.Name] = {
            item1 = 0,
            item2 = 0
        },
        [player2.Name] = {
            item1 = 0,
            item2 = 0
        }
}

You would want to do something like this:

table.insert(TableName,{--[[Info]]})

I tried this:

			table.insert(duels, 
				{
					[1] = {
						[player1.Name] = {
							item1 = 0,
							item2 = 0
						},
						[player2.Name] = {
							item1 = 0,
							item2 = 0
						}
					}
				}
			)
local Table1 = {}
local Table2 = {
    {
        [player1.Name] = {
            item1 = 0,
            item2 = 0
        },
        [player2.Name] = {
            item1 = 0,
            item2 = 0
        }
    }
}

table.insert(Table1, Table2[1])

is this what you want?

Each Individual table would need to be inserted within the existing table, In other words your creating a dictionary where your adding a table within a table if you understand what I mean.

This is what I want

			table.insert(duels, 
				[1] = {
					[player1.Name] = {
						item1 = 0,
						item2 = 0
					},
					[player2.Name] = {
						item1 = 0,
						item2 = 0
					}
				}
			)
			table.insert(duels, {
					[player1.Name] = {
						item1 = 0,
						item2 = 0
					},
					[player2.Name] = {
						item1 = 0,
						item2 = 0
					}
				}
			)

you have to do this

Can I still get it with [1] after that

Im assuming you want a dictionary?

largetable[1] = {
        [player1.Name] = {
            item1 = 0,
            item2 = 0
        },
        [player2.Name] = {
            item1 = 0,
            item2 = 0
        }
}

what do you need the [1] for?

is the table you are inserting part of another table?

Yes it is a part of another table

table.insert(duels, OtherTable[1])

Mishaho is this what you were looking for?

You can just directly assign your sub-table to an index in your parent table.

local myTable = {}
local mySubTable = { <stuff> }
myTable[1] = mySubTable

Note that it puts a reference to your subtable there, not a copy of the subtable.

local duels = {
  [1] = { 

   }
}

duels[1][Player1.Name]  = table.create(2) 

Player1.item1 = 0 
Player1.item2 = 0

local Player1 = table.insert(duels[1],duels[1][Player1.Name])
1 Like

Sorry about that but here’s an example:

local duels = {
  [1] = {}
}

-- Creating a player's Info

duels[1][Player1.Name]  = table.create(2) 

duels[1][Player1.Name].item1 = 0 
duels[1][Player1.Name].item2 = 0

table.insert(duels[1],duels[1][Player1.Name])

this worked in the way i wanted it to