1 | local OriginalTable = { Coins = 0 , Diamonds = 0 , } |
2 | local UpdatedTable = { Coins = 0 , Diamonds = 0 , Table = { Table 2 = { Table 3 = { Table 4 = { Table 5 = { Alice = 0 } , Asd = { } } } } } } |
I want Original Table to have things UpdatedTable has
but is there a way I can do something like getdescendants and add them?
I know you can just add a table by doing OriginalTable['Table'] = UpdatedTable.Table but
what if I wanted to add something inside that table
for example
1 | UpdatedTable = { Table = { NewTable = { } , AnotherTableUpdate = { } } } |
so I needed Something like :GetDescendants
You could have a loop running in the background in a coroutine, looping through updatedTable. run type(v)
, and check if type(v) == "table"
or not. If it is a table, loop through v, check if there's tables, repeat. If type(v) ~= "table"
then add it to originalTable.
If you need further clarification then please comment.
If this solution worked for you, please mark as correct!