What I’m trying to achieve is making a straight line (a Part instance) between 2 existing Parts.
The problem I’m having is how do I make it so that the created Part is always connected from, let’s say p1
to p2
(1st and 2nd pre-existing Part, respectively).
I tried using the half-way point with CFrame.new and using the lookAt
arg to make it look at p2
but this changed nothing - the part was still perpendicular to where I expected it to be. I don’t want to take the easy way out of just rotating it with CFrame.Angles since I think that isn’t the right approach - at least, it’s not how I’d like to approach it. I could be totally wrong and in this mess for that exact reason though.
My current code is here:
local Illustrator = {};
function Illustrator.new(p1, p2, props)
local Distance = (p1.Position - p2.Position).Magnitude;
local BoltLine = Instance.new('Part');
BoltLine.Size = Vector3.new(Distance, 0.25, 0.25);
BoltLine.CFrame = CFrame.new(p1.CFrame:lerp(p2.CFrame, 0.5).Position, p2.Position);
BoltLine.CanCollide = false;
BoltLine.Anchored = true;
BoltLine.Parent = workspace;
end;
return Illustrator;
The current result is this (‘Front’ face highlighted in Orange):
https://i.gyazo.com/1780512839eef035ac57f5fce2405c8a.png