Hello, i’ve been trying to make a script that allows a part to be positioned in between two parts, so at first i used orientation and position to set its location but the model’s welds wouldnt follow the part as i had to use :PivotTo(), so i did so by converting my Vector3 orientation and position to a CFrame, however the orientation isnt right for some reasons.
Here is the code that calculates position orientation and that turns it into CFrame
local ori = ((articulation.FrontAt.Value.Orientation+articulation.BackAt.Value.Orientation)/2)-Vector3.new(90,0,0)
local pos = (articulation.FrontAt.Value.Position+articulation.BackAt.Value.Position)/2
local gcf = CFrame.new( pos ) * CFrame.Angles( math.rad(ori.X),math.rad(ori.Y),math.rad(ori.Z))
And here is a screenshot of what it does instead of working properly
local gcf = CFrame.lookAt(pos, articulation.BackAt.Value.Position)
Then you have to make sure where your part should be looking at, in this case it is looking at articulation.BackAt.Value.Position. To make it look up you would do something like pos + Vector.new(0,1,0).
If you look at the documentation on Orientation you will notice that it is not that simple to use it with CFrames.