Part rotation to CFrame.Angles

I basically tried to rotate a player using humanoidRootPart.Orientation = Vector3.new(x,y,z).
That didn’t work.

Then I wanted to use this:
HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.CFrame.Position) * CFrame.Angles(x, y, z)

However, I noticed that the orientation property of a part/character is not of 360 degrees.

I typed in numbers in the cframe.angles() but got different results than expected. There is some sort of discrepancy between CFrame.Angles and part.Orientation.

But I am not sure what.

Thanks for any help!

1 Like

HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.CFrame.Position) * CFrame.Angles(math.rad(x), math.rad(y), math.rad(z))
You must convert degrees to radians to use degrees for .Angles

Angles uses radians, while orientation uses degrees.

3 Likes

Yep also use CFrame.fromOrientation as is different from CFrame.Angles the key is the order.

CFrame.Angles ( number rx, number ry, number rz )
Equivalent to fromEulerAnglesXYZ.

CFrame.fromOrientation ( number rx, number ry, number rz )
Equivalent to fromEulerAnglesYXZ

2 Likes

@Winbloo @dthecoolest
Thank you very much, it now works - but I got one more question.

I typed this:
character.HumanoidRootPart.CFrame = CFrame.new(character.HumanoidRootPart.CFrame.Position) * CFrame.Angles(math.rad(0), math.rad(90), math.rad(0))

But I would want the script to ADD 90 degrees everytime it gets “fired”. Now it just sets it to 90.

I would want it to be like this:
90
180
etc.

So the character moves 360 degrees around his own character. Thanks!

What you are doing is correct, but CFrame.Angles components are utilized with radians and not degrees. Try Winbloo’s solution and see if it works.

Also I recommend changing

CFrame.new(HumanoidRootPart.CFrame.Position)

to just

HumanoidRootPart.CFrame

Given the fact that you are removing the orientation components of that CFrame making it 0.

1 Like

This should work with what I recommended with my previous reply.

1 Like

Thank you very much! Works perfectly!

1 Like