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?
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.