If you want just a straight line, ROBLOX already has a CFrame constructor for you to use, as well as the nifty Lerp
method of Vector3s.
1 | local p 1 = workspace.Part 1. Position |
2 | local p 2 = workspace.Part 2. Position |
4 | local part = Instance.new( "Part" , workspace) |
5 | part.FormFactor = Enum.FormFactor.Custom |
6 | part.Size = Vector 3. new((p 2 - p 1 ).magnitude, . 2 , . 2 ) |
8 | local midP = p 1 :Lerp(p 2 , . 5 ) |
9 | part.CFrame = CFrame.new(midP, p 2 ) |
If the part you're creating is an arrow mesh or some other thing where the point it's actually facing is important, you can change the p2
in that last line to p1
to point it at that position instead.