How correctly multiply Part.CFrame * CFrame.Angles()?

I’m making building game. But I have a problem - I can’t correctly multiply two CFrames.
One example from my code: I have Block with Orientation: 0, 180, 90. I need change This Block Orientation to 0, 0, 0. I make this:

Block.CFrame = Block.CFrame * CFrame.Angles(-math.rad(Block.Orientation.X), -math.rad(Block.Orientation.Y), -math.rad(Block.Orientation.Z))

But instead of getting Block orientation 0, 0, 0 I receive Orientation 0, 0, 180. I receive this problem with 7 other orientations, but another 16 Orientations work perfectly. (I have all Blocks are rotated only 90 degrees → 0, 90, 180, -180, -90.)
Can someone tell me what I’m making wrong?

Sorry if I make any mistakes, I’m not good in English.

Try CFrame.fromEulerAnglesXYZ()

To have rotation 0,0,0

Block.CFrame = CFrame.new(Block.CFrame.Position)

Try CFrame.fromOrientation(0, math.rad(180), math.rad(-90)).

I already tryed it. And other fromAngles, fromOrientation and etc

This’s not work. And I forget say one important thing - Block is model. And idk why sometimes models don’t act like just parts.

Is there any errors in the output?

OwO magicalmariomario
Try CFrame.fromOrientation(0, math.rad(180), math.rad(-90)) .

This’s don’t change result. Block orientation after changing is 0, 0, 180.

1 Like

No. After printing (-math.rad(Block.Orientation.X), -math.rad(Block.Orientation.Y), -math.rad(Block.Orientation.Z)) it will print 0, -180, -90. But errors not exsist.
Idk, but why (0, 180, 90) + (0, -180, -90) = (0, 0, 180)?

local part = workspace.Part

part.CFrame = part.CFrame * (part.CFrame - part.CFrame.p):Inverse()

This will always reset the rotation to 0, 0, 0
If you want to make it more customizable, then you can use this:

local part = workspace.Part
local x, y, z = part.CFrame:ToOrientation()

part.CFrame = part.CFrame * CFrame.fromOrientation(x, 0, z):Inverse() -- Keep it flat on the ground but can rotate left to right
2 Likes