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

How would you insert a table within a table?

Hello, I am making a DataStore for an inventory system, the title says it all, but I will give an example for more detail.

This is what I want the table to start out as:

local inventory = {

}

But how would I insert a table within it such as:

local inventory = {
	Slot1 = {
		item = "Sword"
		amount = 1
		imageid = 0
	}
}

Help is highly appreciated! Thanks! :D

2 comments

0

They same way you insert any other kind of value into a table.

0

Example : Tab["NewTable"]={"Values","Values",3,9}

1 answer

✓ Accepted answer

Just use table.insert(). It would simply be:

NewTable = {Item = "Sword", amount = 1, imageid = 0}
table.insert(inventory, 1, NewTable) 

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