Skip to content

datatypes

Roblox-mirror value types (Vector3, CFrame, Color3, UDim2, Enum, BrickColor, and more), with the same constructors, properties, methods, and operators you know from Roblox.

Vector3.new(x: number?, y: number?, z: number?) -> Vector3

Constructs a Vector3, defaulting any omitted component to 0.

local v = Vector3.new(1, 2, 3)

Vector3.zero -> Vector3

Static Vector3(0, 0, 0).

local v = Vector3.zero

Vector3.one -> Vector3

Static Vector3(1, 1, 1).

local v = Vector3.one

Vector3.xAxis -> Vector3

Static Vector3(1, 0, 0).

local v = Vector3.xAxis

Vector3.yAxis -> Vector3

Static Vector3(0, 1, 0).

local v = Vector3.yAxis

Vector3.zAxis -> Vector3

Static Vector3(0, 0, 1).

local v = Vector3.zAxis

vec.X, vec.Y, vec.Z -> number

Read-only component accessors.

print(v.X, v.Y, v.Z)

vec.Magnitude -> number

Vector length.

print(v.Magnitude)

vec.Unit -> Vector3

Normalized copy of the vector, zero-length vectors return the zero vector unchanged.

local u = v.Unit

vec:Dot(other: Vector3) -> number

Dot product of two vectors.

local d = v:Dot(Vector3.new(0,1,0))

vec:Cross(other: Vector3) -> Vector3

Cross product of two vectors.

local c = v:Cross(Vector3.new(0,1,0))

vec:Lerp(goal: Vector3, alpha: number) -> Vector3

Linear interpolation between two vectors.

local m = a:Lerp(b, 0.5)

vec:Abs() -> Vector3

Component-wise absolute value.

local a = v:Abs()

vec:Ceil() -> Vector3

Component-wise ceiling.

local c = v:Ceil()

vec:Floor() -> Vector3

Component-wise floor.

local f = v:Floor()

vec:Sign() -> Vector3

Component-wise sign (-1, 0, or 1).

local s = v:Sign()

vec:Max(...other: Vector3) -> Vector3

Component-wise maximum across this vector and any number of others.

local m = a:Max(b, c)

vec:Min(...other: Vector3) -> Vector3

Component-wise minimum across this vector and any number of others.

local m = a:Min(b, c)

vec:FuzzyEq(other: Vector3, epsilon: number?) -> boolean

True if all components are within epsilon (default 1e-5) of each other.

if a:FuzzyEq(b, 0.01) then end

vec:Angle(other: Vector3, axis: Vector3?) -> number

Angle in radians between two vectors, signed about an optional axis.

local ang = a:Angle(b)

+, -, * (Vector3|number), / (Vector3|number), unary -, ==, tostring

Arithmetic operators; multiply/divide accept either another Vector3 (component-wise) or a scalar.

local v = a + b * 2

Vector2.new(x: number?, y: number?) -> Vector2

Constructs a Vector2, defaulting any omitted component to 0.

local v = Vector2.new(1, 2)

Vector2.zero -> Vector2

Static Vector2(0, 0).

local v = Vector2.zero

Vector2.one -> Vector2

Static Vector2(1, 1).

local v = Vector2.one

Vector2.xAxis -> Vector2

Static Vector2(1, 0).

local v = Vector2.xAxis

Vector2.yAxis -> Vector2

Static Vector2(0, 1).

local v = Vector2.yAxis

vec.X, vec.Y -> number

Read-only component accessors.

print(v.X, v.Y)

vec.Magnitude -> number

Vector length.

print(v.Magnitude)

vec.Unit -> Vector2

Normalized copy of the vector, zero-length vectors return the zero vector unchanged.

local u = v.Unit

vec:Dot(other: Vector2) -> number

Dot product of two vectors.

local d = v:Dot(Vector2.new(0,1))

vec:Cross(other: Vector2) -> number

2D cross product (scalar) of two vectors.

local c = v:Cross(Vector2.new(0,1))

vec:Lerp(goal: Vector2, alpha: number) -> Vector2

Linear interpolation between two vectors.

local m = a:Lerp(b, 0.5)

vec:Abs() -> Vector2

Component-wise absolute value.

local a = v:Abs()

vec:Ceil() -> Vector2

Component-wise ceiling.

local c = v:Ceil()

vec:Floor() -> Vector2

Component-wise floor.

local f = v:Floor()

vec:Sign() -> Vector2

Component-wise sign (-1, 0, or 1).

local s = v:Sign()

vec:Max(...other: Vector2) -> Vector2

Component-wise maximum across this vector and any number of others.

local m = a:Max(b)

vec:Min(...other: Vector2) -> Vector2

Component-wise minimum across this vector and any number of others.

local m = a:Min(b)

+, -, * (Vector2|number), / (Vector2|number), unary -, ==, tostring

Arithmetic operators; multiply/divide accept either another Vector2 (component-wise) or a scalar.

local v = a + b * 2

Color3.new(r: number?, g: number?, b: number?) -> Color3

Constructs a Color3 from 0-1 channel values, defaulting omitted channels to 0.

local c = Color3.new(1, 0, 0)

Color3.fromRGB(r: number?, g: number?, b: number?) -> Color3

Constructs a Color3 from 0-255 channel values.

local c = Color3.fromRGB(255, 0, 0)

Color3.fromHSV(h: number, s: number, v: number) -> Color3

Constructs a Color3 from hue/saturation/value in 0-1 range.

local c = Color3.fromHSV(0.5, 1, 1)

Color3.fromHex(hex: string) -> Color3

Constructs a Color3 from a hex string, an optional leading ‘#’ is stripped.

local c = Color3.fromHex("#FF0000")

col.R, col.G, col.B -> number

Read-only 0-1 channel accessors.

print(c.R, c.G, c.B)

col:Lerp(other: Color3, alpha: number) -> Color3

Linear interpolation between two colors.

local m = a:Lerp(b, 0.5)

col:ToHSV() -> (number, number, number)

Returns hue, saturation, value in 0-1 range.

local h, s, v = c:ToHSV()

col:ToHex() -> string

Returns an uppercase 6-digit hex string with no leading ‘#’.

local hex = c:ToHex()

==, tostring

Equality and string conversion.

if a == b then end

CFrame.new() | CFrame.new(pos: Vector3) | CFrame.new(pos: Vector3, lookAt: Vector3) | CFrame.new(x: number, y: number, z: number) | CFrame.new(x,y,z, r00..r22: number x9) -> CFrame

Constructs a CFrame; overload chosen by argument count and type (identity, position-only, look-at, position, or full 3x4 component list).

local cf = CFrame.new(0, 5, 0)

CFrame.lookAt(pos: Vector3, target: Vector3, up: Vector3?) -> CFrame

Constructs a CFrame at pos oriented toward target, up defaults to (0,1,0).

local cf = CFrame.lookAt(Vector3.zero, Vector3.new(0,0,-1))

CFrame.Angles(rx: number, ry: number, rz: number) -> CFrame

Constructs a rotation-only CFrame from Euler angles in radians (RxRyRz order).

local cf = CFrame.Angles(0, math.pi/2, 0)

CFrame.fromEulerAnglesXYZ(rx: number, ry: number, rz: number) -> CFrame

Alias for CFrame.Angles.

local cf = CFrame.fromEulerAnglesXYZ(0, 0, 0)

cf.Position, cf.p -> Vector3

Translation component of the CFrame.

print(cf.Position)

cf.X, cf.Y, cf.Z -> number

Position components.

print(cf.X, cf.Y, cf.Z)

cf.RightVector, cf.XVector -> Vector3

World-space right (rotation column 0).

print(cf.RightVector)

cf.UpVector, cf.YVector -> Vector3

World-space up (rotation column 1).

print(cf.UpVector)

cf.LookVector -> Vector3

World-space forward, negated rotation column 2.

print(cf.LookVector)

cf.ZVector -> Vector3

Raw rotation column 2 (not negated, unlike LookVector).

print(cf.ZVector)

cf:Inverse() -> CFrame

Returns the inverse transform.

local inv = cf:Inverse()

cf:Lerp(goal: CFrame, alpha: number) -> CFrame

Interpolates position linearly and rotation via quaternion slerp.

local m = a:Lerp(b, 0.5)

cf:GetComponents() -> (number x12)

Returns the 12 raw components: position xyz then the 3x3 rotation matrix row-major.

local x,y,z, r00,r01,r02, r10,r11,r12, r20,r21,r22 = cf:GetComponents()

cf:components() -> (number x12)

Alias for GetComponents.

local vals = {cf:components()}

cf:ToWorldSpace(other: CFrame) -> CFrame

Composes this CFrame with another (self * other).

local w = base:ToWorldSpace(offset)

cf:ToObjectSpace(other: CFrame) -> CFrame

Returns other expressed relative to this CFrame (inverse(self) * other).

local rel = base:ToObjectSpace(world)

cf:PointToWorldSpace(point: Vector3) -> Vector3

Transforms a local point to world space.

local w = cf:PointToWorldSpace(Vector3.new(0,1,0))

cf:PointToObjectSpace(point: Vector3) -> Vector3

Transforms a world point to local space.

local l = cf:PointToObjectSpace(worldPoint)

cf:VectorToWorldSpace(vec: Vector3) -> Vector3

Rotates a direction vector into world space, ignoring translation.

local w = cf:VectorToWorldSpace(Vector3.new(1,0,0))

cf:VectorToObjectSpace(vec: Vector3) -> Vector3

Rotates a direction vector into local space, ignoring translation.

local l = cf:VectorToObjectSpace(worldDir)

cf:ToEulerAnglesXYZ() -> (number, number, number)

Returns Euler angles in radians (Roblox YXZ decomposition).

local rx, ry, rz = cf:ToEulerAnglesXYZ()

cf:ToOrientation() -> (number, number, number)

Alias for ToEulerAnglesXYZ.

local rx, ry, rz = cf:ToOrientation()

cf:ToEulerAngles() -> (number, number, number)

Alias for ToEulerAnglesXYZ.

local rx, ry, rz = cf:ToEulerAngles()

* (CFrame|Vector3), + (Vector3), - (Vector3), ==, tostring

Multiply composes with another CFrame or transforms a Vector3; add/subtract offset the position by a Vector3.

local moved = cf * CFrame.new(0,1,0)

UDim.new(scale: number?, offset: number?) -> UDim

Constructs a UDim, defaulting omitted components to 0.

local u = UDim.new(0.5, 10)

u.Scale, u.Offset -> number

Read-only component accessors.

print(u.Scale, u.Offset)

+, -, ==, tostring

Component-wise arithmetic and equality.

local u = a + b

UDim2.new(xScale, xOffset, yScale, yOffset: number?) | UDim2.new(x: UDim, y: UDim) -> UDim2

Constructs a UDim2 from four scalars or two UDims.

local u = UDim2.new(0.5, 0, 1, -10)

UDim2.fromScale(x: number?, y: number?) -> UDim2

Constructs a UDim2 with only scale components set.

local u = UDim2.fromScale(0.5, 0.5)

UDim2.fromOffset(x: number?, y: number?) -> UDim2

Constructs a UDim2 with only offset components set.

local u = UDim2.fromOffset(100, 50)

u.X, u.Width -> UDim

The X-axis UDim (scale/offset pair).

print(u.X.Scale)

u.Y, u.Height -> UDim

The Y-axis UDim (scale/offset pair).

print(u.Y.Offset)

u:Lerp(goal: UDim2, alpha: number) -> UDim2

Linear interpolation of all four components.

local m = a:Lerp(b, 0.5)

+, -, ==, tostring

Component-wise arithmetic and equality.

local u = a + b

Rect.new(minOrX: Vector2|number?, maxOrY: Vector2|number?, maxX: number?, maxY: number?) -> Rect

Constructs a Rect from two Vector2 corners or four numbers.

local r = Rect.new(0, 0, 100, 50)

r.Min, r.Max -> Vector2

Corner accessors.

print(r.Min, r.Max)

r.Width, r.Height -> number

Derived size (Max minus Min per axis).

print(r.Width, r.Height)

==, tostring

Equality and string conversion.

if a == b then end

NumberRange.new(min: number, max: number?) -> NumberRange

Constructs a NumberRange, max defaults to min.

local r = NumberRange.new(0, 10)

r.Min, r.Max -> number

Read-only bound accessors.

print(r.Min, r.Max)

==, tostring

Equality and string conversion.

if a == b then end

TweenInfo.new(time: number?, easingStyle: EnumItem|number?, easingDirection: EnumItem|number?, repeatCount: number?, reverses: boolean?, delayTime: number?) -> TweenInfo

Constructs a TweenInfo; easingStyle/Direction accept a raw number or an Enum.* EnumItem.

local ti = TweenInfo.new(1, Enum.EasingStyle.Sine)

TweenInfo.Time/EasingStyle/EasingDirection/RepeatCount/Reverses/DelayTime

Section titled “TweenInfo.Time/EasingStyle/EasingDirection/RepeatCount/Reverses/DelayTime”

ti.Time -> number, ti.EasingStyle -> number, ti.EasingDirection -> number, ti.RepeatCount -> number, ti.Reverses -> boolean, ti.DelayTime -> number

Read-only field accessors.

print(ti.Time, ti.Reverses)

Color4.new(r: number?, g: number?, b: number?, a: number?) -> Color4

Constructs a Color4, alpha defaults to 1.

local c = Color4.new(1, 0, 0, 0.5)

c.R, c.G, c.B, c.A -> number

Read-only channel accessors.

print(c.R, c.A)

==, tostring

Equality and string conversion.

if a == b then end

Ray.new(origin: Vector3, direction: Vector3) -> Ray

Constructs a Ray from an origin and direction.

local r = Ray.new(Vector3.zero, Vector3.new(0,0,-1))

ray.Origin, ray.Direction -> Vector3

Read-only field accessors.

print(ray.Origin, ray.Direction)

ray.Unit -> Ray

Copy of the ray with the direction normalized.

local u = ray.Unit

ray:ClosestPoint(point: Vector3) -> Vector3

Closest point on the ray (clamped to t >= 0) to the given point.

local p = ray:ClosestPoint(target)

ray:Distance(point: Vector3) -> number

Distance from the ray (clamped to t >= 0) to the given point.

local d = ray:Distance(target)

Region3.new(min: Vector3, max: Vector3) -> Region3

Constructs an axis-aligned Region3 from min/max corners.

local r = Region3.new(Vector3.new(-5,-5,-5), Vector3.new(5,5,5))

r.Size -> Vector3

Derived size (max minus min).

print(r.Size)

r.CFrame -> CFrame

Identity-rotation CFrame centered on the region.

print(r.CFrame)

Enum.<Type>.<Name> -> EnumItem

Curated set of Enum types/values (EasingStyle, EasingDirection, UserInputType, UserInputState, KeyCode, Material, HumanoidStateType, KeybindMode, FontWeight, FontStyle, Font), not the full Roblox enum set.

local style = Enum.EasingStyle.Sine

item.Name -> string, item.Value -> number, item.EnumType -> string

Read-only field accessors on an EnumItem.

print(item.Name, item.Value)

==, tostring

Equality compares value and enum type; tostring formats as Enum.Type.Name.

if a == b then end

RaycastResult.Position/Normal/Distance/Instance/Material

Section titled “RaycastResult.Position/Normal/Distance/Instance/Material”

rr.Position -> Vector3, rr.Normal -> Vector3, rr.Distance -> number, rr.Instance -> Instance|nil, rr.Material -> EnumItem

Read-only fields on a raycast hit result. You get one back from a raycast; it is not user-constructible. Instance may be nil when the hit object can’t be resolved.

local hit = workspace:Raycast(origin, dir); print(hit.Position)

NumberSequence.new(keypoints: {NumberSequenceKeypoint}) | NumberSequence.new(value: number, value2: number?) -> NumberSequence

Constructs from an explicit keypoint array, or a constant/two-point sequence from one or two numbers.

local ns = NumberSequence.new(0, 1)

ns.Keypoints -> {NumberSequenceKeypoint}

Rebuilds and returns the keypoint array.

for _, kp in ns.Keypoints do end

ColorSequence.new(keypoints: {ColorSequenceKeypoint}) | ColorSequence.new(color: Color3, color2: Color3?) -> ColorSequence

Constructs from an explicit keypoint array, or a constant/two-point sequence from one or two colors.

local cs = ColorSequence.new(Color3.new(1,0,0))

cs.Keypoints -> {ColorSequenceKeypoint}

Rebuilds and returns the keypoint array.

for _, kp in cs.Keypoints do end

NumberSequenceKeypoint.new(time: number, value: number, envelope: number?) -> NumberSequenceKeypoint

Constructs a keypoint, envelope defaults to 0.

local kp = NumberSequenceKeypoint.new(0, 1)

NumberSequenceKeypoint.Time/Value/Envelope

Section titled “NumberSequenceKeypoint.Time/Value/Envelope”

kp.Time, kp.Value, kp.Envelope -> number

Read-only field accessors.

print(kp.Time, kp.Value)

ColorSequenceKeypoint.new(time: number, color: Color3) -> ColorSequenceKeypoint

Constructs a keypoint from a time and Color3.

local kp = ColorSequenceKeypoint.new(0, Color3.new(1,0,0))

kp.Time -> number, kp.Value -> Color3

Read-only field accessors.

print(kp.Time, kp.Value)

Font.new(family: string, weight: EnumItem|number?, style: EnumItem|number?) -> Font

Constructs a Font from a family string; weight/style accept a raw number or Enum.FontWeight/FontStyle EnumItem, defaulting to Regular/Normal.

local f = Font.new("rbxasset://fonts/families/Roboto.json")

Font.fromName(name: string, weight: EnumItem|number?, style: EnumItem|number?) -> Font

Builds a Font from a short family name via the rbxasset families path convention.

local f = Font.fromName("Roboto")

Font.fromEnum(fontEnum: EnumItem|string) -> Font

Builds a Font from an Enum.Font EnumItem (or raw name string), defaulting to SourceSans if unrecognized.

local f = Font.fromEnum(Enum.Font.Gotham)

f.Family -> string, f.Bold -> boolean, f.Weight -> EnumItem, f.Style -> EnumItem

Read-only field accessors; Bold is derived from weight >= 600.

print(f.Family, f.Bold)

==, tostring

Equality compares family, weight and style; tostring formats as a descriptive string.

if a == b then end

PhysicalProperties.new(density: number, friction: number?, elasticity: number?, frictionWeight: number?, elasticityWeight: number?) -> PhysicalProperties

Constructs a PhysicalProperties; friction/elasticity default to 0, the two weights default to 1.

local pp = PhysicalProperties.new(0.7)

pp.Density, pp.Friction, pp.Elasticity, pp.FrictionWeight, pp.ElasticityWeight -> number

Read-only field accessors.

print(pp.Density)

==, tostring

Equality and string conversion.

if a == b then end

Vector3int16.new(x: number?, y: number?, z: number?) -> Vector3int16

Constructs a Vector3int16, components truncated to int16.

local v = Vector3int16.new(1, 2, 3)

v.X, v.Y, v.Z -> number

Read-only integer component accessors.

print(v.X, v.Y, v.Z)

+, -, ==, tostring

Component-wise arithmetic (results truncated to int16) and equality.

local v = a + b

Vector2int16.new(x: number?, y: number?) -> Vector2int16

Constructs a Vector2int16, components truncated to int16.

local v = Vector2int16.new(1, 2)

v.X, v.Y -> number

Read-only integer component accessors.

print(v.X, v.Y)

+, -, ==, tostring

Component-wise arithmetic (results truncated to int16) and equality.

local v = a + b

BrickColor.new() | BrickColor.new(color: Color3) | BrickColor.new(name: string) | BrickColor.new(r,g,b: number) | BrickColor.new(number: integer) -> BrickColor

Constructs a BrickColor from a Color3 (nearest palette match), a palette name, RGB numbers, or a palette number; falls back to Medium stone grey (194) if unresolved.

local bc = BrickColor.new("Bright red")

BrickColor.random() -> BrickColor

Returns a BrickColor chosen from the palette via a self-contained xorshift RNG.

local bc = BrickColor.random()

BrickColor.White/Gray/DarkGray/Black/Red/Green/Blue/Yellow

Section titled “BrickColor.White/Gray/DarkGray/Black/Red/Green/Blue/Yellow”

BrickColor.White() -> BrickColor (etc.)

Static convenience constructors for common palette entries.

local bc = BrickColor.Red()

bc.Number -> integer, bc.Name -> string, bc.Color -> Color3, bc.r/bc.R, bc.g/bc.G, bc.b/bc.B -> number

Read-only field accessors; r/g/b (and uppercase variants) are 0-1 channel values, unresolved palette numbers fall back to Medium stone grey’s RGB.

print(bc.Name, bc.Color)

==, tostring

Equality compares palette number; tostring returns the palette name (empty string if unknown).

if a == b then end