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

Cloning an Objects Children? [Script Included]

Asked by
KAAK82 16
10 years ago
function CloneAllChildren(OldPar, NewPar)
for _,v in ipairs(OldPar) do
v:Clone().Parent = NewPar
end
end

CloneAllChildren(Workspace.Model, Workspace)

would that work like that? (even though am doing something else)...

3 answers

Log in to vote
0
Answered by 10 years ago

This is how you do it.

local Children = {} -- leave this empty

function Copy(Parent) -- Parent is the object that you want to get all of the child
    for i, object in pairs(Parent:GetChildren()) do
        table.insert(Children, object)
    end
end

function Paste(Parent) -- Parent here is the parent you want to paste to
    for i, child in ipairs(Children) do
        child.Parent = Parent
        table.remove(Children, i)
    end
end

Copy(Workspace.Model)
Paste(Workspace)
0
k, thnx... I already found 1 but this was helpful :d KAAK82 16 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

Um, I don't believe the variable "v" was necessarily designed as a part/model so it wouldn't be able to be "cloned." Therefore, it wouldn't work regardless. I also am not sure why "CloneAllChildren" is down on the bottom.

It's just pretty confusing. I'd say that script is both beyond repairing and nil.

0
its the nam eof the function, and also, its a friend that gave me this script... so am looking for ways to clone an objects children... but I cant seem to find the answer :( :'( KAAK82 16 — 10y
Log in to vote
-1
Answered by 10 years ago

People, CALM DOWN. It only takes a few lines goddamnit. e_o You dont need all of that 17 line stuff ._.

function CloneAllChildren(OldPar, NewPar)
    for i,v in pairs(OldPar:GetChildren()) do
        v:Clone().Parent = NewPar
        wait()
    end
end

CloneAllChildren(Workspace.Model, Workspace)

This'll work as long as the destinations are valid.

0
wich ones do I change? is it just the bottom ones? KAAK82 16 — 10y
0
yes TochiWasHere 10 — 10y

Answer this question