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

Can you make table.insert insert the value to a specific place in the table?

So I have a table where I want to insert a number into and I want it to be in the second key "[2]" but I wanted to know if it's possible.

3 comments

0

tab[2] = value

0

Yeah it works. But you can't use table.insert to do that  unfortunately https://gyazo.com/5910c7a1c3a2464aec58f9c8e307806e

1

You actually can you table.insert to do that. table.insert(table, index, value)

1 answer

✓ Accepted answer

In lua you can do exactly what you want with the table.insert(t, i, v)

Example:

local t = {}

table.insert(t, 2, value) -- Where 2 is the index you are inserting the value to

2 comments

0

oh nice to know

0

Learning something new everyday :)

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