How to insert a new dictionary table

I was making a tycoon game when I reached the part where I needed to save the objects a player purchased with buttons. I came across the idea of adding a table in my table where data will be stored, which will be named a number, which is the ButtonID a player purchased. This is how I scripted it:

table.insert(Data.Tycoon.Floors[Floor.Name].Buttons, {
	Time = os.date()
})

And I realized that you couldn’t add any argument for the table name. After a bit, I realized the table I inserted was an array, and I didn’t want that, due to the fact that the name would equal the ButtonID the player bought. I did some research and I couldn’t find anything that can support my issue. The most relevant post was this, but either way, I couldn’t understand what the post actually was trying to say, so I was left with no choice but to post a new topic.

if its a luau table then you can add values to it without table.insert()

Data.Tycoon.Floors[Floor.Name].Buttons[Time] = os.date()

if it’s a reference to an instance then you can use the :SetAttribute() method

Data.Tycoon.Floors[Floor.Name].Buttons:SetAttribute("Time", os.date())
1 Like

You can do

Data.Tycoon.Floors[Floor.Name].Buttons[myTableName] = {Time=os.date()}
1 Like

@GE_0E and @azqjanna, I need to instance the table button too, not just the timestamp.

I’m confused, which pieces of data do you want to be accessible in your table?