Line of parts starting at the end of the previous part

Im trying to achieve this. The red lines are supposed to represent the blue lines touching. Not sure how to do this or find any resource on it.

1 Like

You can set the position and size of a part to make a line segment between two points like this:

function placePartOnSegment(part, p0, p1)
    local diff = p1 - p0
    local dist = diff.Magnitude
    part.Size = Vector3.new(part.Size.X, part.Size.Y, dist)
    part.CFrame = CFrame.new(p0, p1) * CFrame.new(0, 0, dist/2)
end

The logic is that it puts the center of the part at the CFrame that starts at p0 and points at p1. It translates that along the length axis of the part by half the length of the part so that it isn’t the center that’s at p0, but one of the ends. It also makes the part long enough to span the distance between p0 and p1.

2 Likes