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

Im trying to insert the opposite of the value in a new table and its not working?

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.

1 answer

✓ Accepted answer

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

1 comment

0

Thanks!

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