How Do I Change Table Index?

I am having trouble figuring out how to change the index of a object in a table? I tried searching the forums and it’s either not there or my query is not good. So, how do you change the index of a object in a table?

Example:

local myTable = {thing1,thing2,thing3}

How do I change thing3 index to the index of thing 1?

Do you have an example of this? Your question is unclear

Example:

local myTable = {thing1,thing2,thing3}

How do I change thing3 index to the index of thing 1?
Does that example help?

Is this what you mean?

local myTable = {thing1,thing2,thing3}

local myTable = {thing3,thing2,thing1}

No, I mean like, changing the index of something, not redefining the table.

local myTable = {thing1,thing2,thing3}
for i,v in pairs(myTable) do
    if v == thing1 then
        table.insert(myTable,i,thing3)
    elseif v == thing3 then
        table.insert(myTable,i,thing1)
    end
end

I don’t completely understand what you’re trying to do here but I think this is what you mean.

1 Like

Ah, that may work, since im using getchildren then adding an object, I will try right now.

1 Like