Ad
Log in to vote
0

How to clone an object with it's children?

Asked by
Grazer022 128
4 days ago
Edited 4 days ago

I am making a script that would clone a ball and it’s effects (children) to the workspace.


NRGremoteEvent = game.ReplicatedStorage.nrgEvent NRGremoteEvent.OnServerEvent:Connect(function(plr) local NRGclone = game.ReplicatedStorage.NRGfolder.EnergyBmain:Clone() NRGclone.Parent = game.Workspace NRGclone.Position = Vector3.new(0,30,30) end)

The thing is, that it only clones the main (EnergyBmain). It doesn’t clone it’s children which are particles and such. They’re stored in a folder (NRGfolder) and is located inside ReplicatedStorage. I’m very lost on what to do, i can’t find a way to clone the whole thing (main and children), please help. Thanks.

(on mobile rn.)

0
im even more lost as to why its only cloning the object and not the descendants, a variety of reasoning behind this. for example if you clone a single object on server and have its descendants on client greatneil80 2465 — 3d

1 answer

Log in to vote
0
Answered by 4 days ago
NRGremoteEvent = game.ReplicatedStorage.nrgEvent

NRGremoteEvent.OnServerEvent:Connect(function(plr)
    local NRG = game.ReplicatedStorage.NRGfolder.EnergyBmain:GetChildren()
    for i, v in pairs(NRG) do
        wait()
        local NRGclone = v:Clone()
        NRGclone.Parent = game.Workspace
        NRGclone.Position = Vector3.new(0,30,30)
    end
end)

So what I did was I gathered the children, and cloned them one by one in a for in pairs() loop.

Ad

Answer this question