How to insert a table inside a table?

To insert a table using table.insert do:

table.insert(Table.TableIndex, {StuffHere})
1 Like

Ok, so what I’m tryna do is, I’m tryna insert a table of this

,
(just the specific one for example “Cannon”).
Here is the inventory table inside the player -
image

and here is the script -

The bindable finds item type[Towers] then rarity[Basic] then finally, the item. which is the final table I want to put into the player’s inventory.

My problem here is, I don’t know how.
Now what I did in final was that, but it kinda broke it.
image

inventory is a variable, adding data to it will be useless if not saved, you need to “set” the data too

Yes, I didn’t show it, but I was using datastore2
image

is userDataStoreName and dataKey the same?

Yes. Other things does save, I’m not worried about the datasaving because it does work, I’m just tryna insert a table here.

are you sure it saves or is it showing up a default table? saving on a different key changes a lot
I am not able to see one of these variables but they shoul be the same for the saving and loading to have the same key

as in this data adding function, you’re using the dataKey as key at loading and userDataStoreName as key at saving

Yea it is the same. Datasaving does work once again. The key is just inside a module.
I’m just tryna insert a table inside a table here buddy.

try to print variable inventory before and after, I want to see the table so I can research it a bit more.

(so after making the inventory variable and after setting the data after the if statement)

I have to loop through it. You can’t print a table.

afbeelding
you can print a table since quite recently

You want me to print this image
variable? The :Set() function is basically just like setasync. It will not affect the value.

I know, print userdata at getting and at settings -w-

I did image
image

include the rest of the function with teh changed tables, test the print on this one


-w-

above I did post the changed tables. It just broke into random stuff

Try using:

inventory[itemType][rarity][item] = findItem

Instead of:

table.insert(inventory[itemType][rarity], {findItem})
4 Likes

then the name will be used as a key instead of those 1’s if that’s what you want me to try to fix

1 Like

Thank you > o < this makes me realised how dumb I am. Does using “=” would add it.

Now left with this (works now ty)
image

1 Like