Changing part cframe between 2 part

I’m trying to change created part cframe like this

partbetween,

I did that, lol that was so easy.

local P1 = script.Parent.P1

local P2 = script.Parent.P2

local CreatedPart = Instance.new("Part",workspace)

CreatedPart.Anchored = true

local distance = (P1.Position-P2.Position).Magnitude

CreatedPart.Size = Vector3.new(2, 2, distance)

CreatedPart.CFrame = CFrame.new(P1.Position,P2.Position) * CFrame.new(0,0, -distance/2)
1 Like