Roblox CFrame API

Posted on

Roblox CFrame API, which is also known as Roblox Coordinate Frame API, is the name of the user data item containing position and rotation data, this one is able to be used to accurately position a thing called BaseParts through their CFrame property, that unlike Position, allows the part to be placed overlapping another part and be rotated.

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

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

IF you want to create he rotated CFrame at the origin, you can use:

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

according to the official page of CFrame on Wiki, it is worth nothing that the rotations are not applied simultaneously, but sequentially. Basically, the previous command will rotate in the part’s X-axis, then the part’s Y-axis, and then the part’s Z-axis.


One of the most interesting things is that anything with the property that is the CFrame value, for instance, the thing called CFrame property of the BasePart object, is hidden. Aside from that one, the value property of the CframeValue is also hidden. That is the main reason why it needs to be modified from the script.

Roblox CFrame API is one of the basic types that is available in the Roblox Lua, this one is able to be called by using several different constructors. The first constructor is CFrame.new(). This one creates the identity CFrame. The second one is CFrame.new(Vector3 v). This one creates the CFrame from offset v. The third one is CFrame.new(Vector3 v, Vector3 I). This one creates the CFrame from offset v looking at point I. The fourth one is CFrame.new(Number x, Number y, number z). This one creates the CFrame from offset (x, y, z). The fifth one is CFrame.new(Number x, Number y, Number z, Number qx, Number qy, Number qz, Number qw). This one creates CFrame from offset (x, y, z) and quaternion (qx, qy, qz, qw). The sixth one is CFrame.new(Number x, Number y, Number z, Number R00, Number R01, Number R02, Number R10, Number R11, Number R12, Number R20, Number R21, Number R22). This one creates CFrame from offset (x, y, z) and rotation matrix (R00, R01, R02, R10, R11, R12, R20, R21, R22). The seventh one is CFrame.fromEulerAnglesXYZ(Number x, Number y, Number z) or CFrame.Angles(Number x, Number y, Number z). This one creates the rotated CFrame at (0, 0, 0) rotated around the three axes in order (relative to the CFrame). The angles in radians. The last one is CFrame.fromAxisAngle)Vector3 v, Number r). This one create the rotated CFrame from the unit vector and the rotation in radians.

Aside from the constructors, Roblox CFrame API has members, methods, and operations. For the members, there are Vector3, Number x, Number y, Number z, and Vector3 lookVector. For the oeprators, there are CFrame * CFrame, CFrame * Vector3, CFrame + Vector2, and CFrame – Vector3. Go to Wiki for details information of it.

Leave a Reply

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