I’m trying to position my model at a certain point using SetPrimaryPartCFrame(), and while the position is correct, I can’t seem to get the rotation right. I want its rotation to match the Orientation of another part.
CFrame.Angles applies the angles in XYZ order, which matches the way the Rotation property works.
The Orientation property’s angles are ordered YXZ (which generally makes more sense than XYZ). You should use CFrame.fromOrientation instead, this function also applies the angles in YXZ order.
Somewhat recently YXZ ordered properties/functions were added (Part.Orientation, Attachment.Orientation, CFrame.fromOrientation, CFrame.fromEulerAnglesYXZ …), which are semi-replacing the older XYZ stuff (Part.Rotation, Attachment.Rotation, CFrame.Angles, CFrame.fromEulerAnglesXYZ …), I believe.
Probably simply because the YXZ order is much easier to work with in most cases.
Apparently the Orientation property is in degrees, but all those CFrame functions take radians, so you’d have to convert those degrees to radians first using math.rad.
(Although using Orientation/fromOrientation to copy the rotation of a CFrame works perfectly fine, I’d definitely use the method @As8D described, though.)
As8D’s solution still doesn’t help me. This is really frustrating since I’m trying to get a whole model to move, and only one part is anchored and welded to all the other parts, which are unanchored. If I just do CFrame.new(Vector3.new()), it’ll remove the orientation.
If it’s just an issue of moving a single anchored part, you don’t need to bother with the rest of the model since they’ll adapt the orientation by nature of being welded to the anchored part. Get the rotated CFrame of your target part and apply it as a multiplication to the model root’s current CFrame.