[Already have a solution but looking for another way]How can I put some space between every part I clone?

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!

2 Likes

Can you not just use a wait to space them out?

1 Like
local amount = 5

local pos = clonedpart.Position + Vector3.new(amount * i, 0, 0)
clonedpart.CFrame = CFrame.new(pos)
4 Likes

Thank you soo much! I have been trying to find a solution for an entire day!

Is there another technique of doing it without using the index?

sure, you could do something like

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.

^sorry if the above is not clear.

1 Like

Thank you! But I’m kind of confused about how to use his script.

Edit: Nvm it worked Thank you!