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

What is the easiest way to "clone" a table?

Let's say I had table A:

local A = {1,2,3,4,5}

and I want to assign that table to a variable so I can edit it:

local B = A

But whenever I do something to "B", Table "A" gets changed as well. I know why, but what I'm asking is how would I "clone" this table, so that I could edit it without changing the original table?

NOTE: I've used a for loop to insert values from Table A into B, but the for loop becomes useless if I have more table within tables or tables with indexes.

1 answer

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