Hello, so I’m trying to make a script that will clone a part 10 times and put some space between each one, here is what I did:
for i = 1, 10 do
local bruh = workspace.part
local clonedpart = part:Clone()
clonedpart.Parent = workspace
clonedpart.Name = 'part'..i
local pos = clonedpart.Position
clonedpart.CFrame = CFrame.new(pos)
wait(.4)
end
But it doesn’t seem to work, it works for the first part but not for the others how can i fix this?
Thank you!
local amount = 5
function clonePart(lastPart) --lastPart would be the last part that you cloned
local clonedpart = part:Clone()
clonedpart.Parent = workspace
local pos = lastPart.Position + Vector3.new(amount, 0, 0)
clonedpart.CFrame = CFrame.new(pos)
return clonedpart
end
--example on how you would run the function above
local part = clonePart(clonedPart)
part = clonePart(part)
part = clonePart(part)
so every time you call clonePart(clonePart), it will clone the part and move it over by 5
without the index, you will move the new part you are cloning over 5 from the original, but with the index, the first time you move it 5, then 10, then 15, esc.
with the function above, you move it 5 from the last part you cloned.