Roblox CFrame Rotation

Posted on

Roblox CFrame or Roblox Coordinate Frame is known as the user data item containing position and rotation data. This one can be used to accurately position BaseParts through the CFrame property, that unlike Position, allows the part to be placed overlapping another part and be rotated.

Fortunately, you are able to position the part just like you would using the Position property.

part.CFrame =, 6, 2) — Places the part at point {1, 6, 2) in the workspace

In order to create the rotated CFrame at the origin, you can use:

part.CFrame = CFrame.Angles(math.rad(45), math.rad(90), math.rad(180))

This one means nothing that the rotations are not applied simultaneously, but sequentially. So, the last command rotates in the X-axis of the part, then the Y-axis of the part, and then the Z-axis of the part.

One of the most interesting facts is that anything with the property that is the CFrame value, for instance, the CFrame property of the BasePart object, is hidden. The thing called the value property of the CFrameValue is hidden as well, thus needing to be modified from the script.

According to the official website of Roblox Developer, in order to create the rotated CFrame, you can use the CFrame.Angles() constructor, providing the rotation angle in the radians for the desired axes. Please take a note that the parameters to CFrame.Angles() must be specified in radians, not degrees. If you want to use the degrees, you can just simply use the math.rad() converter.

Aside from rotating the CFrame, there are some other CFrame basics that you have to know. The first one is positionong the CFrame. Apparently, the empty CFrame is able to be created with at the default position of 0, 0, 0 in the game world. In order to position the CFrame at the certain point however, you have to provide X, Y, and Z parameters to As the alternative, you are able to provide the new Vector3 position to and get the same result.

The second one is facing toward the point. One of the most powerful benefits of is the ability to point the front surface of the CFrame at the certain point in the world. you can consider the one that places the redBlock part at 0,3, 0 and then points its front surface at the blueCube part.

The third one is offsetting the CFrame. In some cases, you will have to offset the object by the certain number of studs from the current position. This one can be done by simply adding or subtracting the Vector3 to or from the new CFrame created at the position of the object. For your information, the same technique is also able to be used to offset the object from the position of another object. In this case, the Vector3 is added to the new CFrame created at the position of the blue cube instead of the position of the block. You can visit Roblxo Developer for more information about anything.

Leave a Reply

Your email address will not be published. Required fields are marked *