# How to convert CFrame.Angles rotation to regular orientation?

Here I have an angle, that by default is relative to the part I’m rotating `CFrame.Angles(0, math.rad(90), 0)`. Is there any way to convert this into Orientation?

I am aware that orientation uses degrees rather than radians, so an obvious solution would be to use `math.deg()` orientation however, is also relative to the world. Not relative to the part.

I’ve tried using this `basePart.Orientation = referenceCFrame:PointToWorldSpace(Vector3.New(0, 90, 0))` It doesn’t seem to work however.

What exactly am I doing wrong here?

How do I convert something like this `CFrame.Angles(0, math.rad(90), 0)`, into something that could be put into orientation?

EDIT: The first reply seems to work, but I’m curious to know what @elonrocket was going to say.

1 Like

You could probably use `CFrame:ToOrientation` (the dev hub does say it’s an approximation though, but it looks close enough).

``````local p1 = workspace.p1

local X, Y, Z = Angle:ToOrientation()
X, Y, Z = math.deg(X), math.deg(Y), math.deg(Z)

p1.CFrame = CFrame.new() * Angle

local o = p1.Orientation
print(X, Y, Z, "(Orientation From CFrame)")
print(o.X, o.Y, o.Z, "(Actual Part Orientation)")
``````
``````> 21.357552449692 49.397898587108 23.019310153999 (Orientation From CFrame)
> 21.360000610352 49.400001525879 23.020000457764 (Actual Part Orientation)``````
10 Likes

Representing, converting, and replicating euler angles is really risky business
While an interesting concept in theory, just as a postnote, if this is for anything meaningful Id find another way to accomplish what you want to do

1 Like

I’ve tried using this `basePart.Orientation = referenceCFrame:PointToWorldSpace(Vector3.New(0, 90, 0))` It doesn’t seem to work however.

You’re setting the orientation of the base part to a position relative to `referenceCFrame`, which isn’t rotation so its giving you inaccurate results.

How do I convert something like this `CFrame.Angles(0, math.rad(90), 0)` , into something that could be put into orientation?

Second reply is your answer, but here’s my answer. Get the x,y, z components of the angle and convert them to degrees via `math.deg` since it’s going to return those values in radians and orientation works with degrees.

Assuming you’re using `CFrame.Angles`, which applies rotation in order: Z, Y, X, get the angles via `CFrame:ToEulerAnglesXYZ()` and convert them to degrees.

``````local Angle = CFrame.Angles(math.rad(31), math.rad(45), 0)

local x, y, z = Angle:ToEulerAnglesXYZ()
x, y, z = math.deg(x), math.deg(y), math.deg(z) -- convert to degrees
``````
1 Like