How Can I Set a Part's Orientation to Specific Values Using CFrame

I have a part with an orientation of -45, 0, 0, but when I rotate it -15 degrees on the Y-axis, the orientation changes to -43.079, 20.754, -14.511 instead of -45, -15, 0. I thought this might have something to do with ToObjectSpace or ToWorldSpace, so I tried using those, but I didn’t get the result I wanted. How can I use the CFrame library to set the orientation to exactly -45, -15, 0?

part.CFrame = CFrame.new(part.Position) * CFrame.Angles(math.rad(-45), math.rad(-15), 0)

The orientation is still “-43.08, -20.754, 14.511”

I see that… working on it. this is always a hassle, wish I could just remeber this one.

nope, your answer is right. no idea why it isn’t working for them.

edit: works from my testing

change CFrame.Angles to CFrame.fromOrientation

it works i checked with command bar

part.CFrame = CFrame.new(part.Position) * CFrame.fromOrientation(math.rad(-45), math.rad(-15), 0)
1 Like

Ahhhh, I knew it was something like this … fromOrientation… Got it!

1 Like