CFrame
Represents a position and rotation in three-dimensional space.
Behavior
CFrame stores a position and rotation. Multiplication composes transforms:
a * b applies b relative to a. Multiplication order affects the result.
Transform operations return new values.
Summary
The transform with zero translation and no rotation.
Creates a rotation from X, Y, and Z angles in radians.
CFrame.fromAxisAngle(axis: Vector3, angle: number): CFrameCreates a rotation about the specified axis.
CFrame.fromEulerAngles(rx: number, ry: number, rz: number, order: EnumItem?): CFrameCreates a rotation from Euler angles in radians using the selected rotation order.
Creates a rotation from X, Y, and Z Euler angles in radians.
Creates a rotation from Euler angles in radians, applied in Y-X-Z order.
Creates a transform from a position and basis vectors.
Creates a rotation from orientation angles in radians.
Creates a transform at at facing the supplied direction.
Creates a transform at at facing target.
Creates a transform.
The forward unit vector.
The position component as a Vector3.
The right-facing unit vector.
The rotation of this transform with its translation set to zero.
The up-facing unit vector in the transformed coordinate frame.
The X component of the translation.
The transform's local X basis vector in world space.
The Y component of the translation.
The transform's local Y basis vector in world space.
The Z component of the translation.
The transform's local Z basis vector in world space.
FuzzyEq(other: CFrame, epsilon: number?): booleanReturns whether the transforms differ by no more than the supplied tolerance.
GetComponents(): (number, number, number, number, number, number, number, number, number, number, number, number)Returns the three translation components followed by the nine rotation-matrix components.
Inverse(): CFrameReturns the inverse transform.
Lerp(other: CFrame, alpha: number): CFrameInterpolates position and rotation toward another frame.
Orthonormalize(): CFrameReturns a transform whose rotation basis is orthonormal.
PointToObjectSpace(args: ...Vector3): ...Vector3Converts world-space points into this transform's local space.
PointToWorldSpace(args: ...Vector3): ...Vector3Converts local-space points into world space.
ToAxisAngle(): (Vector3, number)Returns the rotation axis and angle in radians.
ToEulerAnglesXYZ(): number, number, numberReturns the rotation as X, Y, and Z Euler angles in radians.
ToEulerAnglesYXZ(): number, number, numberReturns Euler angles in radians using Y-X-Z rotation order.
ToObjectSpace(other: CFrame): CFrameTransforms a world-space frame into coordinates relative to this frame.
ToOrientation(): number, number, numberReturns orientation angles in radians.
ToWorldSpace(other: CFrame): CFrameTransforms a local frame into world space relative to this frame.
VectorToObjectSpace(args: ...Vector3): ...Vector3Rotates world-space vectors into local space without applying translation.
VectorToWorldSpace(args: ...Vector3): ...Vector3Rotates local-space vectors into world space without applying translation.
Constructors
Angles
CFrame.Angles(rx: number, ry: number, rz: number): CFrameCreates a rotation from X, Y, and Z angles in radians. Use math.rad to convert degrees.
fromAxisAngle
CFrame.fromAxisAngle(axis: Vector3, angle: number): CFrameCreates a rotation about the specified axis. The angle is in radians.
fromEulerAngles
CFrame.fromEulerAngles(rx: number, ry: number, rz: number, order: EnumItem?): CFrameCreates a rotation from Euler angles in radians using the selected rotation order.
fromEulerAnglesXYZ
CFrame.fromEulerAnglesXYZ(rx: number, ry: number, rz: number): CFrameCreates a rotation from X, Y, and Z Euler angles in radians. Equivalent to Angles.
fromEulerAnglesYXZ
CFrame.fromEulerAnglesYXZ(rx: number, ry: number, rz: number): CFrameCreates a rotation from Euler angles in radians, applied in Y-X-Z order.
fromMatrix
Creates a transform from a position and basis vectors. The optional third basis vector completes the rotation matrix.
fromOrientation
CFrame.fromOrientation(rx: number, ry: number, rz: number): CFrameCreates a rotation from orientation angles in radians.
identity
CFrame.identity: CFrameThe transform with zero translation and no rotation.
lookAlong
Creates a transform at at facing the supplied direction. The optional up vector controls the roll reference.
lookAt
Creates a transform at at facing target. The optional up vector controls the roll reference.
new
CFrame.new(…)Creates a transform. Three numbers specify a position with no rotation. Two positions specify a transform at the first position facing the second.
Properties
LookVector
CFrame.LookVector: Vector3The forward unit vector.
Position
CFrame.Position: Vector3The position component as a Vector3.
RightVector
CFrame.RightVector: Vector3The right-facing unit vector.
Rotation
CFrame.Rotation: CFrameThe rotation of this transform with its translation set to zero.
UpVector
CFrame.UpVector: Vector3The up-facing unit vector in the transformed coordinate frame.
X
CFrame.X: numberThe X component of the translation.
XVector
CFrame.XVector: Vector3The transform's local X basis vector in world space.
Y
CFrame.Y: numberThe Y component of the translation.
YVector
CFrame.YVector: Vector3The transform's local Y basis vector in world space.
Z
CFrame.Z: numberThe Z component of the translation.
ZVector
CFrame.ZVector: Vector3The transform's local Z basis vector in world space.
Methods
FuzzyEq
CFrame:FuzzyEq(other: CFrame, epsilon: number?): booleanReturns whether the transforms differ by no more than the supplied tolerance.
GetComponents
CFrame:GetComponents(): (number, number, number, number, number, number, number, number, number, number, number, number)Returns the three translation components followed by the nine rotation-matrix components.
Inverse
CFrame:Inverse(): CFrameReturns the inverse transform. Multiplying a transform by its inverse produces the identity transform.
Lerp
CFrame:Lerp(other: CFrame, alpha: number): CFrameInterpolates position and rotation toward another frame. Rotation follows the shortest path.
Orthonormalize
CFrame:Orthonormalize(): CFrameReturns a transform whose rotation basis is orthonormal.
PointToObjectSpace
Converts world-space points into this transform's local space. Translation is included.
PointToWorldSpace
Converts local-space points into world space. Translation is included.
ToAxisAngle
CFrame:ToAxisAngle(): (Vector3, number)Returns the rotation axis and angle in radians.
ToEulerAnglesXYZ
CFrame:ToEulerAnglesXYZ(): number, number, numberReturns the rotation as X, Y, and Z Euler angles in radians. Multiple angle triples can represent the same orientation.
ToEulerAnglesYXZ
CFrame:ToEulerAnglesYXZ(): number, number, numberReturns Euler angles in radians using Y-X-Z rotation order.
ToObjectSpace
CFrame:ToObjectSpace(other: CFrame): CFrameTransforms a world-space frame into coordinates relative to this frame.
ToOrientation
CFrame:ToOrientation(): number, number, numberReturns orientation angles in radians.
ToWorldSpace
CFrame:ToWorldSpace(other: CFrame): CFrameTransforms a local frame into world space relative to this frame.
VectorToObjectSpace
Rotates world-space vectors into local space without applying translation.
VectorToWorldSpace
Rotates local-space vectors into world space without applying translation.
Operators
__add · __eq · __mul · __sub · __tostring · __type
Example
local transform = CFrame.new(0, 5, 0) * CFrame.Angles(0, math.rad(45), 0)Used by
Accessory · AlignOrientation · Attachment · BasePart · Camera · CFrameValue · CharacterController · Collider · DecalProjector · FogVolume · GeometryPart · IntersectOperation · LightProbeVolume · Model · Motor6D · NegateOperation · Part · PlayerMouse · Pose · ReflectionProbe · SceneFrame · Seat · SpawnLocation · Terrain · Tool · UnionOperation · VehicleSeat · VRService · Workspace