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

How to clone tables and give them a parent?

Hello,

Im trying to make a plot saving and loading system by using datastore. I can print the table by unpacking it and it prints the saved parts of the plor. But I can't copy them and give them a parent by unpacking it.

If anyone knows how to clone and give a parent to a table.Any help would be awesome.

1 answer

You can use a for - loop to get all of the assets in the table, then you can clone them and parent them.

for i, TableChild in pairs(table) do -- Replace table with the actual table.
    local newTableChild = TableChild:Clone()
    newTableChild.Parent = workspace.TableFolder -- Replace with where you want it to be parented.
end

3 comments

0

what is tablechild in this script like table:GetChildren or unpack(table)?

0

TableChikd is what we define the parts in the "table" table, everything that's in that table is defined as TableChild. The for - loop will loop through each child and run the stuff inside the loop on them.

0

I got this error now: 22:37:13.215 - ServerScriptService.PlotSystem:38: attempt to call a nil value

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