This gives optimization for clones?

I want to publish my first tutorial in the forum, and this is about optimization for clones. I got this script:

local SelectedItem = game.ServerStorage.Map
local SelectedItemGroup = Instance.new("Model")
for i,v in pairs(SelectedItem:GetChildren()) do
    local Part = v:Clone() --map clone
    Part.Parent = map
    wait(0.1)
end

So it’s exactly, the same thing as this:

local SelectedItem = game.ServerStorage.Map
local SelectedItemClone = SelectedItem:Clone()
SelectedItemClone.Parent = game.Workspace

But i don’t know if the first example is more optimized than the second, that’s my question. Thanks for reading :+1: :123:

1 Like

The second example will clone all of the parts at once, and then parent them making the server replicate and the client render all of the parts of the same time which can really reduce frame rate.

The first example however, is procedural and will replicate and render them one at a time.

In terms of optimisation the second would probably be slightly better as it completely clones it instead of iterating through the children, however in terms of damage to frame rate or ping the first comes out better.

1 Like