Im trying to print the opposite of a, b, a, a but its not working, help
a = true b = false new={ } bool = { a, b, a, a} print(table.unpack(bool, 1, #bool)) for k, v in pairs(bool) do for i = 1, #bool do table.insert(new, not v) end end print(table.unpack(new, #new))
Output : true false true true False
Edit(forgot to add iteration, changes to false once but wont insert the others.
You don't need another for = i.. statement in your loop as the for k,v in pairs(bool) basically already does that, so it just needs to be like this. Also you don't use table.unpack, just unpack when using print.
a = true b = false new = { } bool = {a, b, a, a} print(unpack(bool, 1, #bool)) -- Returns: true false true true local new = {} for _,v in pairs(bool) do table.insert(new,not v) end print(unpack(new, 1, #new)) -- Returns: false true false false