CFrame.Angles not giving the wanted result

I have the part where I want to set the position and orientation to specific values, but for some reason the orientation doesn’t get set to that value and the value keeps changing.

So I want to have a part position set to {-1, -0.2, 0.51} with the orientation of {-40, -80.782, 90}.
The position gets set fine but the orientation gets set to {-5.91, -82.913, 129.634}.
I have tried to use :Inverse() but that just gives me the result of {49.126, -79.192, -165.83} for the orientation

My current script is:

part.CFrame = CFrame.new(-1, -0.2, 0.51) * CFrame.Angles(math.rad(-40), math.rad(-80.782), math.rad(90))

Any help would be great!

1 Like

Maybe the math.rad has some bugs while trying to convert radians to degrees.

Try this:

local r1 = -40 * math.pi/180
local r2 = -80.782 * math.pi/180
local r3 = 90 * math.pi/180 -- or just math.pi/2

part.CFrame = CFrame.new(-1, -0.2, 0.51) * CFrame.Angles(math.rad(-40), math.rad(-80.782), math.rad(90))

CFrame.Angles is not CFrame.fromOrientation.

The anglea are applied different, try messing around with XYZ vs YXZ or CFrame.fromOrientation.

1 Like

This gives the same output as my codes does for the orientation {-5.91, -82.913, 129.634}

part.CFrame = (CFrame.new(-1, -0.2, 0.51) * CFrame.Angles((-40 * math.pi/180), (-80.782 * math.pi/180), (90 * math.pi/180)))

fromOrientation seems to work, thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.