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

How do I perform efficient cloning?

Asked by
neoG457 315 Moderation Voter
9 years ago
local   Carbon = Instance.new("Part")
        Carbon.Anchored = false
        Carbon.CanCollide = false       
        Carbon.Size = Vector3.new(1.5, 1.5, 1.5)
        Carbon.BrickColor = BrickColor.new("Black")
        Carbon.Parent = Player.Character

local   Carbon2 = Carbon:Clone()
local   Carbon3 = Carbon:Clone()
local   Carbon4 = Carbon:Clone()
local   Carbon5 = Carbon:Clone()
local   Carbon6 = Carbon:Clone()
local   Carbon7 = Carbon:Clone()
local   Carbon8 = Carbon:Clone()
local   Carbon9 = Carbon:Clone()
local   Carbon10 = Carbon:Clone()

I really want a faster way to make multiple clones without having to copy and paste clones all the time.

1 answer

Log in to vote
2
Answered by
Spectrobz 140
9 years ago

You would use a "for" loop, which would do it as many times as you want. Example:

for i = 1,10 do
    -- Code
end

Would play the same function 10 times. ( i would be the "repetition ammount")

So in your case you would replace " -- code " with a "Carbone:Clone()"

If you want to save each clone as a value, you would use a table. I'll let you read this http://wiki.roblox.com/index.php?title=Table

( You can insert models in a table)

Ad

Answer this question