# Line of parts starting at the end of the previous part

How do I make a line of parts, that start at the end of the other?

1 Like
``````for i = 0, 9 do --change 9 to create more parts
local part = Instance.new("Part")
part.Size = Vector3.new(4, 1, 2) --default size
local sizeX = part.Size.X
part.Position = Vector3.new(sizeX*i, 0, 0)
part.Parent = workspace
end
``````

Feel free to add more properties like material, transparency, color etc.

1 Like

how would you set the origin of the first part

``````for i = 0, 9 do --change 9 to create more parts
local part = Instance.new("Part")
part.Size = Vector3.new(4, 1, 2) --default size
local sizeX = part.Size.X
part.Position = Vector3.new(sizeX*i+0, 0, 0) --change the zeros
part.Parent = workspace
end
``````
1 Like
``````for i = 0, 9 do --change 9 to create more parts
local part = Instance.new("Part")
part.Anchored = true
part.Size = Vector3.new(4, 1, 2) --default size
local sizeX = part.Size.X
part.Position = Vector3.new(sizeX*i+0, 0, 0) --change the zeros
part.Parent = workspace
end
``````

I forgot that parts are not anchored when they are created, this will fix that.

This will also work for all 3 axis:

``````for i = 0, 9 do --change 9 to create more parts
local part = Instance.new("Part")
part.Anchored = true
part.Size = Vector3.new(4, 1, 2) --default size
local sizeY = part.Size.Y
part.Position = Vector3.new(0, sizeY*i+0, 0) --change the zeros
part.Parent = workspace
end
``````
``````for i = 0, 9 do --change 9 to create more parts
local part = Instance.new("Part")
part.Anchored = true
part.Size = Vector3.new(4, 1, 2) --default size
local sizeZ = part.Size.Z
part.Position = Vector3.new(0, 0, sizeZ*i+0) --change the zeros
part.Parent = workspace
end
``````
1 Like

How would I change the orientation? Or perhaps use cframe instead of position?

``````for i = 0, 9 do --change 9 to create more parts
local part = Instance.new("Part")
part.Anchored = true
part.Size = Vector3.new(4, 1, 2) --default size
local sizeX = part.Size.X
part.Position = Vector3.new(sizeX*i+0, 0, 0) --change the zeros
part.Parent = workspace
part.Orientation = Vector3.new(0, 0, 0)
end
``````

Just add an additional line of code to change the â€śOrientationâ€ť property of the created parts. The same can be done for the other â€śPropertiesâ€ť too (like material, transparency, reflectance).

Sorry for the misundestanding, I meant change the direction the line faces. I can change the xyz value of the vector, but is there a way to perhaps make the line face infront of a character through cframe or the such?

I added an additional line for orientation. If you want CFrame then you can likely get the CFrame of the HumanoidRootPart of the character and use that to manipulate the position at which the line starts.