Question, How Would I Clone An Object and Position It?

So… I’m trying to Make something a lot easier for myself. I’m trying to make a giant stack of blocks. So please, All answers help.

What do you mean by this? You’re trying to clone many parts at once?

1 Like

No @wrdJus , I’m trying to clone 1 part Many times.

Oh. I see, you can do Part:Clone(). Replace the Part with your variable. With the next few lines, you can make a loop using while task.wait(number) do - replace number with the amount of seconds you want each cloning to delay. It should look something like this:

while task.wait(number) do
         Part:Clone()
end

:slight_smile: :slight_smile: But how Would i position it?

Part1 = workspace.Part1
Part2 = workspace.Part2

PartC = Part1:Clone()
PartC.CFrame = Part2.CFrame

You can also use Position

PartC.Position = Part2.Position

Then:

Part1 = workspace.Part1
Part2 = workspace.Part2

while wait() do
PartC = Part1:Clone()
PartC.CFrame = Part2.CFrame
end

Im not sure why people use task.wait() but it works the same so idk

If you want to Destroy a Part without interruption:

Debris = game:GetService("Debris")
-- Inside the loop:
Debris:AddItem(PartC, 2)

I edited my reply. It should work.

Wait @DasKairo, I’m confused, How do I Position the clone?

Just use a for loop like

local origin = CFrame.new(0,10,0)
local offset = Vector3.new(0,1,0) -- vector3 to easily multiply

for i = 1, 100 do -- 100 blocks
      local new = Instance.new("Part") -- or clone it 
      new.CFrame = origin * CFrame.new(offset * i) -- change position by i
      new.Parent = workspace
end

Ok so, to get the Position of the clone, if you follow the example, its the following code: PartC.Position(Our Clone), we add a equal sign to assign a new position which is in this case Part2, if you want it to copy the exact Position and Orientation, use: PartC.CFrame

So the following code:

PartC.Position = Part2.Position -- Assigns Position of PartC to Part2 (Its New position, Part2's Position!)

For CFrame:

PartC.CFrame = Part2.CFrame -- Assigns CFrame (CoordinateFrame)

And remember, Always put in the loop task.wait() or wait()

not really needed for a for loop espically the one i gave since it doesnt go on forever unless you dont want it all to be created instantly

Also By the Way… @DougSwagington, @wrdJus and @DasKairo. How Would I Size a Instance.new()?

Item.Size = Vector3.new(10,10,10) -- Whatever size

-- Tweening
Item:TweenSize(UDim2.new(10,10,10), "InOut", "Sine", 1, false)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.