Do the amount of parts between the 2 blue parts matter? And does the size of the parts that will get in between matter? I might be able to help you out here
Oh… Do you mean that you can’t find a solution to adding parts between these 2 parts with a correct spacing, right?
Edit: Sorry, I didn’t read correct.
local blue1 = workspace.Blue1
local blue2 = workspace.Blue2
local gray = workspace.Gray
local distance = (blue1.Position - blue2.Position).Magnitude
local spacing = distance / 5 -- Divide the distance by the number of parts you want to add plus one
for i = 1, 4 do -- REMEMBER: 4 is the number of parts.
local newGray = gray:Clone()
newGray.Parent = workspace
newGray.Position = blue1.Position - Vector3.new(0, 0, spacing * i)
end
function generateParts(part1, part2, n)
local direction = part2.Position - part1.Position
local offset = direction.Magnitude / (n + 1)
direction = direction.Unit
local position = part1.Position
for i = 1, n do
local p = Instance.new("Part")
p.Anchored = true
p.CanCollide = false
p.Position = position + offset * direction
p.Parent = workspace
position = p.Position
end
end
generateParts(workspace.Part1, workspace.Part2, 5)