evasivedocs
Roblox scriptingLuau 0.748 · 24 guides · 385 API entries
API reference

Data types

Vectors, CFrames, colours, GUI sizes and enums.

Vector3

A point or direction in 3D. Vectors add and subtract, multiply and divide by another Vector3 or a number, and compare with == by value. Unary minus and // (floor division) work too.

22 entries

Vector3.new

function
Vector3.new(x, y, z) -> Vector3

A vector from its components.

Arguments
NameTypeDescription
xnumber
ynumber
znumber
Returns
  • Vector3
Example
Luau
local v = Vector3.new(0, 10, 0)

Vector3.zero

constant

(0, 0, 0).

Returns
  • Vector3

Vector3.one

constant

(1, 1, 1).

Returns
  • Vector3

Vector3.xAxis

constant

(1, 0, 0).

Returns
  • Vector3

Vector3.yAxis

constant

(0, 1, 0).

Returns
  • Vector3

Vector3.zAxis

constant

(0, 0, 1).

Returns
  • Vector3

Vector3.X

field

The x component.

Returns
  • number

Vector3.Y

field

The y component.

Returns
  • number

Vector3.Z

field

The z component.

Returns
  • number

Vector3.Magnitude

field

The length.

Returns
  • number
Example
Luau
local dist = (a - b).Magnitude

Vector3.Unit

field

The same direction with length 1.

Returns
  • Vector3

Vector3:Abs

method
Vector3:Abs() -> Vector3

Each component made positive.

Returns
  • Vector3

Vector3:Angle

method
Vector3:Angle(other) -> number

The angle between the two, in radians.

Arguments
NameTypeDescription
otherVector3
Returns
  • number

Vector3:Ceil

method
Vector3:Ceil() -> Vector3

Each component rounded up.

Returns
  • Vector3

Vector3:Floor

method
Vector3:Floor() -> Vector3

Each component rounded down.

Returns
  • Vector3

Vector3:Cross

method
Vector3:Cross(other) -> Vector3

The cross product.

Arguments
NameTypeDescription
otherVector3
Returns
  • Vector3

Vector3:Dot

method
Vector3:Dot(other) -> number

The dot product.

Arguments
NameTypeDescription
otherVector3
Returns
  • number

Vector3:FuzzyEq

method
Vector3:FuzzyEq(other [, epsilon]) -> boolean

true when the two are equal within epsilon.

Arguments
NameTypeDescription
otherVector3
epsilonoptionalnumber
Returns
  • boolean

Vector3:Lerp

method
Vector3:Lerp(target, alpha) -> Vector3

The point alpha of the way to target (0 is this one, 1 is target).

Arguments
NameTypeDescription
targetVector3
alphanumber
Returns
  • Vector3
Example
Luau
local mid = a:Lerp(b, 0.5)

Vector3:Max

method
Vector3:Max(other) -> Vector3

The larger of each pair of components.

Arguments
NameTypeDescription
otherVector3
Returns
  • Vector3

Vector3:Min

method
Vector3:Min(other) -> Vector3

The smaller of each pair of components.

Arguments
NameTypeDescription
otherVector3
Returns
  • Vector3

Vector3:Sign

method
Vector3:Sign() -> Vector3

-1, 0 or 1 for each component.

Returns
  • Vector3

Vector2

A point or size in 2D: screen positions, Drawing sizes. The same operators as Vector3.

11 entries

Vector2.new

function
Vector2.new(x, y) -> Vector2

A vector from its components.

Arguments
NameTypeDescription
xnumber
ynumber
Returns
  • Vector2
Example
Luau
local center = Vector2.new(960, 540)

Vector2.zero

constant

(0, 0).

Returns
  • Vector2

Vector2.one

constant

(1, 1).

Returns
  • Vector2

Vector2.xAxis

constant

(1, 0).

Returns
  • Vector2

Vector2.yAxis

constant

(0, 1).

Returns
  • Vector2

Vector2.X

field

The x component.

Returns
  • number

Vector2.Y

field

The y component.

Returns
  • number

Vector2.Magnitude

field

The length.

Returns
  • number

Vector2.Unit

field

The same direction with length 1.

Returns
  • Vector2

Vector2:Dot

method
Vector2:Dot(other) -> number

The dot product.

Arguments
NameTypeDescription
otherVector2
Returns
  • number

Vector2:Lerp

method
Vector2:Lerp(target, alpha) -> Vector2

The point alpha of the way to target.

Arguments
NameTypeDescription
targetVector2
alphanumber
Returns
  • Vector2

CFrame

A position and a rotation in 3D. CFrame * CFrame chains two, CFrame * Vector3 moves a point into world space and == compares by value.

25 entries

CFrame.new

function
CFrame.new([x, y, z [, ...]]) -> CFrame

Takes one of these forms. () is the identity. (position) or (x, y, z) is a position with no rotation. (position, lookAt) is a position looking at a point. (x, y, z, qx, qy, qz, qw) is a position and a quaternion. Three numbers followed by nine more is a position and a rotation matrix, row by row. Any other number of arguments raises.

Arguments
NameTypeDescription
...number | Vector3One of the forms above.
Returns
  • CFrame
Example
Luau
local cf = CFrame.new(0, 5, 0)

CFrame.Angles

function
CFrame.Angles(rx, ry, rz) -> CFrame

A rotation from angles in radians, applied in X, Y, Z order.

Arguments
NameTypeDescription
rxnumber
rynumber
rznumber
Returns
  • CFrame
Example
Luau
local turn = CFrame.Angles(0, math.rad(90), 0)

CFrame.fromOrientation

function
CFrame.fromOrientation(rx, ry, rz) -> CFrame

A rotation from angles in radians, applied in Y, X, Z order.

Arguments
NameTypeDescription
rxnumber
rynumber
rznumber
Returns
  • CFrame

CFrame.lookAt

function
CFrame.lookAt(at, target) -> CFrame

A CFrame at at, looking at target.

Arguments
NameTypeDescription
atVector3
targetVector3
Returns
  • CFrame

CFrame.identity

constant

No move, no rotation.

Returns
  • CFrame

CFrame.X

field

The position's x.

Returns
  • number

CFrame.Y

field

The position's y.

Returns
  • number

CFrame.Z

field

The position's z.

Returns
  • number

CFrame.Position

field

The position.

Returns
  • Vector3

CFrame.Rotation

field

The rotation alone, at the origin.

Returns
  • CFrame

CFrame.LookVector

field

Forward (the -Z axis), length 1.

Returns
  • Vector3

CFrame.RightVector

field

Right (the X axis), length 1.

Returns
  • Vector3

CFrame.UpVector

field

Up (the Y axis), length 1.

Returns
  • Vector3

CFrame:GetComponents

method
CFrame:GetComponents() -> number, number, number, number, number, number, number, number, number, number, number, number

x, y, z and the nine rotation matrix values r00 to r22.

Returns
  • number
  • number
  • number
  • number
  • number
  • number
  • number
  • number
  • number
  • number
  • number
  • number

CFrame:Inverse

method
CFrame:Inverse() -> CFrame

The inverse.

Returns
  • CFrame

CFrame:Lerp

method
CFrame:Lerp(target, alpha) -> CFrame

Interpolates position and rotation alpha of the way to target.

Arguments
NameTypeDescription
targetCFrame
alphanumber
Returns
  • CFrame

CFrame:ToWorldSpace

method
CFrame:ToWorldSpace(cf) -> CFrame

cf, given relative to this CFrame, in world space.

Arguments
NameTypeDescription
cfCFrame
Returns
  • CFrame

CFrame:ToObjectSpace

method
CFrame:ToObjectSpace(cf) -> CFrame

cf, given in world space, relative to this CFrame.

Arguments
NameTypeDescription
cfCFrame
Returns
  • CFrame

CFrame:PointToWorldSpace

method
CFrame:PointToWorldSpace(point) -> Vector3

A point relative to the CFrame, in world space.

Arguments
NameTypeDescription
pointVector3
Returns
  • Vector3

CFrame:PointToObjectSpace

method
CFrame:PointToObjectSpace(point) -> Vector3

A world point, relative to the CFrame.

Arguments
NameTypeDescription
pointVector3
Returns
  • Vector3

CFrame:VectorToWorldSpace

method
CFrame:VectorToWorldSpace(direction) -> Vector3

A direction relative to the CFrame, in world space (rotation only).

Arguments
NameTypeDescription
directionVector3
Returns
  • Vector3

CFrame:VectorToObjectSpace

method
CFrame:VectorToObjectSpace(direction) -> Vector3

A world direction, relative to the CFrame (rotation only).

Arguments
NameTypeDescription
directionVector3
Returns
  • Vector3

CFrame:ToEulerAnglesXYZ

method
CFrame:ToEulerAnglesXYZ() -> number, number, number

The rotation as angles in radians, X, Y, Z order.

Returns
  • number
  • number
  • number

CFrame:ToEulerAnglesYXZ

method
CFrame:ToEulerAnglesYXZ() -> number, number, number

The rotation as angles in radians, Y, X, Z order.

Returns
  • number
  • number
  • number

CFrame:ToOrientation

method
CFrame:ToOrientation() -> number, number, number

The same as ToEulerAnglesYXZ.

Returns
  • number
  • number
  • number

Color3

A colour with red, green and blue from 0 to 1.

10 entries

Color3.new

function
Color3.new(r, g, b) -> Color3

A colour from 0 to 1 channels.

Arguments
NameTypeDescription
rnumber
gnumber
bnumber
Returns
  • Color3

Color3.fromRGB

function
Color3.fromRGB(r, g, b) -> Color3

A colour from 0 to 255 channels.

Arguments
NameTypeDescription
rnumber
gnumber
bnumber
Returns
  • Color3
Example
Luau
local red = Color3.fromRGB(255, 0, 0)

Color3.fromHSV

function
Color3.fromHSV(h, s, v) -> Color3

A colour from hue, saturation and value, each 0 to 1.

Arguments
NameTypeDescription
hnumber
snumber
vnumber
Returns
  • Color3

Color3.fromHex

function
Color3.fromHex(hex) -> Color3

A colour from "#rrggbb" or "rrggbb".

Arguments
NameTypeDescription
hexstring
Returns
  • Color3
Example
Luau
Color3.fromHex("#00ff88")

Color3.R

field

Red, 0 to 1.

Returns
  • number

Color3.G

field

Green, 0 to 1.

Returns
  • number

Color3.B

field

Blue, 0 to 1.

Returns
  • number

Color3:ToHex

method
Color3:ToHex() -> string

The colour as "rrggbb".

Returns
  • string

Color3:ToHSV

method
Color3:ToHSV() -> number, number, number

Hue, saturation and value, 0 to 1.

Returns
  • number
  • number
  • number

Color3:Lerp

method
Color3:Lerp(target, alpha) -> Color3

The colour alpha of the way to target.

Arguments
NameTypeDescription
targetColor3
alphanumber
Returns
  • Color3

UDim

One GUI dimension: a scale and a pixel offset.

3 entries

UDim.new

function
UDim.new(scale, offset) -> UDim

A dimension.

Arguments
NameTypeDescription
scalenumber
offsetnumber
Returns
  • UDim

UDim.Scale

field

The fraction of the parent.

Returns
  • number

UDim.Offset

field

Pixels.

Returns
  • number

UDim2

A GUI size or position: two UDims.

5 entries

UDim2.new

function
UDim2.new(xScale, xOffset, yScale, yOffset) -> UDim2

From four numbers, or from two UDims: UDim2.new(x, y).

Arguments
NameTypeDescription
xScalenumber
xOffsetnumber
yScalenumber
yOffsetnumber
Returns
  • UDim2
Example
Luau
UDim2.new(0.5, 0, 0, 20)

UDim2.fromOffset

function
UDim2.fromOffset(x, y) -> UDim2

Pixels only.

Arguments
NameTypeDescription
xnumber
ynumber
Returns
  • UDim2

UDim2.fromScale

function
UDim2.fromScale(x, y) -> UDim2

Scale only.

Arguments
NameTypeDescription
xnumber
ynumber
Returns
  • UDim2

UDim2.X

field

The horizontal part.

Returns
  • UDim

UDim2.Y

field

The vertical part.

Returns
  • UDim

Enum

Roblox enums. Items compare with == and work as table keys.

3 entries

Enum.KeyCode

constant

Keys and mouse buttons: Enum.KeyCode.F, LeftShift, Space, MouseButton1 to MouseButton5, ... An item's Value is its Windows virtual-key code, so either works wherever a key is taken.

Returns
  • Enum
Example
Luau
if input.KeyCode == Enum.KeyCode.E then end

Enum.Material

constant

Part materials (Plastic, Wood, Metal, Neon, ...), as RaycastResult.Material returns them.

Returns
  • Enum

Enum.RaycastFilterType

constant

Exclude and Include, for RaycastParams.FilterType.

Returns
  • Enum