#duplicating/cloning tables doesnt work

4 messages · Page 1 of 1 (latest)

green kite
#

i simply want to clone a table like this:

local parts2 = parts
print(parts2)
table.clear(parts)
print(parts2)

if parts is equal to this:

{1, 5, 32, 12432, 7, 18}

then the output should be:

{1, 5, 32, 12432, 7, 18}
{1, 5, 32, 12432, 7, 18}

but instead its:

{1, 5, 32, 12432, 7, 18}
{}

I think this has to do with the fact that it isnt cloning the table, its making a pointer to that table. How can i not do this?

lost steeple
#

yes tables work that way I think u can use table.clone

green kite
#

thank you

#

works