Need help with table.insert

The question is simple, I want to insert a value into a table but I want it to be like

local TABLE = {
Fire = "http://www.roblox.com/asset/?id=123456789"
}

Instead of

local TABLE = {
"http://www.roblox.com/asset/?id=123456789"
}

But when I try this in my script it will cause a error

table.insert(TABLE, #TABLE + 1, v.Name = v.Image.Value)

-- Preview: Fire = "http://www.roblox.com/asset/?id=123456789" 

How do I insert something like Fire = "http://www.roblox.com/asset/?id=123456789" to a table?

3 Likes

You can do
table.insert{table, fire} then
table[1] = “link”

3 Likes

Just do TABLE[v.Name] = v.Image.Valuetable.insert only inserts to the array part of a table.

4 Likes

I think you mean:

local TABLE = {
["Fire"] = "http://www.roblox.com/asset/?id=123456789"
}

That’s a dictionary btw

The former is still valid, it is syntax sugar for the latter.

2 Likes

I tried

local TABLE = {}

table.insert(TABLE, #TABLE + 1, "Fire")

TABLE["Fire"] = "Test"

print(TABLE["Fire"]) -- Test

and it worked.

Also thanks @sjr04 for the reply