Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to clone tables and give them a parent?

Asked by 4 years ago

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

Log in to vote
0
Answered by
ACHRONlX 255 Moderation Voter
4 years ago

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
0
what is tablechild in this script like table:GetChildren or unpack(table)? DmrGamingX 64 — 4y
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. ACHRONlX 255 — 4y
0
I got this error now: 22:37:13.215 - ServerScriptService.PlotSystem:38: attempt to call a nil value DmrGamingX 64 — 4y
Ad

Answer this question