Have a look at the link I sent. It will work correctly if you use this;
local offset = a.CFrame:toObjectSpace(b.CFrame)
b.CFrame = a.CFrame * offset
T̶h̶e̶ ̶m̶a̶t̶h̶ ̶t̶h̶a̶t̶ ̶J̶a̶r̶o̶d̶ ̶w̶a̶s̶ ̶t̶a̶l̶k̶i̶n̶g̶ ̶a̶b̶o̶u̶t̶ ̶s̶h̶o̶u̶l̶d̶ ̶b̶e̶ ̶t̶h̶e̶ ̶o̶t̶h̶e̶r̶ ̶w̶a̶y̶ ̶a̶r̶o̶u̶n̶d̶ ̶t̶o̶ ̶w̶o̶r̶k̶ ̶p̶r̶o̶p̶e̶r̶l̶y̶,̶ ̶i̶.̶e̶.̶;̶
I was totally wrong, his math was right
You can plug that back into your script and it should get you what you’re after, though I’d recommend the first method I suggested (toObjectSpace) as it’s an explicit operation as opposed to math (which isn’t as easily recognizable)
What do you mean about applying rotations? You can transform your part by some rotation as you could normally with any other CFrame, i.e.
b.CFrame = a.CFrame * offset * CFrame.Angles(0,0,math.pi/4)