Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to convert Euler angles to orientation?

So I'm trying to make one part face another, I can do it with Roblox inbuilt functions but when I do the math myself it doesn't add up. How do I convert from Euler angles back to degrees so it can be used in part orientation?

local BasePart = game.Workspace:WaitForChild("SpawnLocation")
local getToPart = game.Workspace.GetTo
local newCFrame = CFrame.new(BasePart.Position, getToPart.Position)
local x , y , z = newCFrame:ToEulerAnglesXYZ()
BasePart.CFrame = newCFrame
print("Part Orientation: ", BasePart.Orientation)
print("Euler Orientation: ", x , y , z)
print("Euler in Degrees: ", math.deg(x), math.deg(y), math.deg(z))

Output:

Part Orientation: 17.8799992, -112.339996, 0

Euler Orientation: 2.4376466274261 -1.0764619112015 2.4997501373291

Euler in Degrees: 139.66686369582 -61.676724318431 143.22513270621

-- Why is it 139.66 degrees instead of the original 17.87?

1 answer

The euler angles you are using are applied in zyx order but orientation is applied in zxy order. If you want to convert a cframe to euler angles that are applied in zxy order, you can use CFrame:ToEulerAnglesYXZ or CFrame:ToOrientation().

This discussion is preserved as it was. New answers, comments, and votes are closed.