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.
Vector3.new(x, y, z) -> Vector3A vector from its components.
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
z | number |
Vector3
local v = Vector3.new(0, 10, 0)(0, 0, 0).
Vector3
(1, 1, 1).
Vector3
(1, 0, 0).
Vector3
(0, 1, 0).
Vector3
(0, 0, 1).
Vector3
The x component.
number
The y component.
number
The z component.
number
The length.
number
local dist = (a - b).MagnitudeThe same direction with length 1.
Vector3
Vector3:Abs() -> Vector3Each component made positive.
Vector3
Vector3:Angle(other) -> numberThe angle between the two, in radians.
| Name | Type | Description |
|---|---|---|
other | Vector3 |
number
Vector3:Ceil() -> Vector3Each component rounded up.
Vector3
Vector3:Floor() -> Vector3Each component rounded down.
Vector3
Vector3:Cross(other) -> Vector3The cross product.
| Name | Type | Description |
|---|---|---|
other | Vector3 |
Vector3
Vector3:Dot(other) -> numberThe dot product.
| Name | Type | Description |
|---|---|---|
other | Vector3 |
number
Vector3:FuzzyEq(other [, epsilon]) -> booleantrue when the two are equal within epsilon.
| Name | Type | Description |
|---|---|---|
other | Vector3 | |
epsilonoptional | number |
boolean
Vector3:Lerp(target, alpha) -> Vector3The point alpha of the way to target (0 is this one, 1 is target).
| Name | Type | Description |
|---|---|---|
target | Vector3 | |
alpha | number |
Vector3
local mid = a:Lerp(b, 0.5)Vector3:Max(other) -> Vector3The larger of each pair of components.
| Name | Type | Description |
|---|---|---|
other | Vector3 |
Vector3
Vector3:Min(other) -> Vector3The smaller of each pair of components.
| Name | Type | Description |
|---|---|---|
other | Vector3 |
Vector3
Vector3:Sign() -> Vector3-1, 0 or 1 for each component.
Vector3
Vector2.new(x, y) -> Vector2A vector from its components.
| Name | Type | Description |
|---|---|---|
x | number | |
y | number |
Vector2
local center = Vector2.new(960, 540)(0, 0).
Vector2
(1, 1).
Vector2
(1, 0).
Vector2
(0, 1).
Vector2
The x component.
number
The y component.
number
The length.
number
The same direction with length 1.
Vector2
Vector2:Dot(other) -> numberThe dot product.
| Name | Type | Description |
|---|---|---|
other | Vector2 |
number
Vector2:Lerp(target, alpha) -> Vector2The point alpha of the way to target.
| Name | Type | Description |
|---|---|---|
target | Vector2 | |
alpha | number |
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.
CFrame.new([x, y, z [, ...]]) -> CFrameTakes 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.
| Name | Type | Description |
|---|---|---|
... | number | Vector3 | One of the forms above. |
CFrame
local cf = CFrame.new(0, 5, 0)CFrame.Angles(rx, ry, rz) -> CFrameA rotation from angles in radians, applied in X, Y, Z order.
| Name | Type | Description |
|---|---|---|
rx | number | |
ry | number | |
rz | number |
CFrame
local turn = CFrame.Angles(0, math.rad(90), 0)CFrame.fromOrientation(rx, ry, rz) -> CFrameA rotation from angles in radians, applied in Y, X, Z order.
| Name | Type | Description |
|---|---|---|
rx | number | |
ry | number | |
rz | number |
CFrame
CFrame.lookAt(at, target) -> CFrameA CFrame at at, looking at target.
| Name | Type | Description |
|---|---|---|
at | Vector3 | |
target | Vector3 |
CFrame
No move, no rotation.
CFrame
The position's x.
number
The position's y.
number
The position's z.
number
The position.
Vector3
The rotation alone, at the origin.
CFrame
Forward (the -Z axis), length 1.
Vector3
Right (the X axis), length 1.
Vector3
Up (the Y axis), length 1.
Vector3
CFrame:GetComponents() -> number, number, number, number, number, number, number, number, number, number, number, numberx, y, z and the nine rotation matrix values r00 to r22.
numbernumbernumbernumbernumbernumbernumbernumbernumbernumbernumbernumber
CFrame:Inverse() -> CFrameThe inverse.
CFrame
CFrame:Lerp(target, alpha) -> CFrameInterpolates position and rotation alpha of the way to target.
| Name | Type | Description |
|---|---|---|
target | CFrame | |
alpha | number |
CFrame
CFrame:ToWorldSpace(cf) -> CFramecf, given relative to this CFrame, in world space.
| Name | Type | Description |
|---|---|---|
cf | CFrame |
CFrame
CFrame:ToObjectSpace(cf) -> CFramecf, given in world space, relative to this CFrame.
| Name | Type | Description |
|---|---|---|
cf | CFrame |
CFrame
CFrame:PointToWorldSpace(point) -> Vector3A point relative to the CFrame, in world space.
| Name | Type | Description |
|---|---|---|
point | Vector3 |
Vector3
CFrame:PointToObjectSpace(point) -> Vector3A world point, relative to the CFrame.
| Name | Type | Description |
|---|---|---|
point | Vector3 |
Vector3
CFrame:VectorToWorldSpace(direction) -> Vector3A direction relative to the CFrame, in world space (rotation only).
| Name | Type | Description |
|---|---|---|
direction | Vector3 |
Vector3
CFrame:VectorToObjectSpace(direction) -> Vector3A world direction, relative to the CFrame (rotation only).
| Name | Type | Description |
|---|---|---|
direction | Vector3 |
Vector3
CFrame:ToEulerAnglesXYZ() -> number, number, numberThe rotation as angles in radians, X, Y, Z order.
numbernumbernumber
CFrame:ToEulerAnglesYXZ() -> number, number, numberThe rotation as angles in radians, Y, X, Z order.
numbernumbernumber
CFrame:ToOrientation() -> number, number, numberThe same as ToEulerAnglesYXZ.
numbernumbernumber
Color3.new(r, g, b) -> Color3A colour from 0 to 1 channels.
| Name | Type | Description |
|---|---|---|
r | number | |
g | number | |
b | number |
Color3
Color3.fromRGB(r, g, b) -> Color3A colour from 0 to 255 channels.
| Name | Type | Description |
|---|---|---|
r | number | |
g | number | |
b | number |
Color3
local red = Color3.fromRGB(255, 0, 0)Color3.fromHSV(h, s, v) -> Color3A colour from hue, saturation and value, each 0 to 1.
| Name | Type | Description |
|---|---|---|
h | number | |
s | number | |
v | number |
Color3
Color3.fromHex(hex) -> Color3A colour from "#rrggbb" or "rrggbb".
| Name | Type | Description |
|---|---|---|
hex | string |
Color3
Color3.fromHex("#00ff88")Red, 0 to 1.
number
Green, 0 to 1.
number
Blue, 0 to 1.
number
Color3:ToHex() -> stringThe colour as "rrggbb".
string
Color3:ToHSV() -> number, number, numberHue, saturation and value, 0 to 1.
numbernumbernumber
Color3:Lerp(target, alpha) -> Color3The colour alpha of the way to target.
| Name | Type | Description |
|---|---|---|
target | Color3 | |
alpha | number |
Color3
UDim.new(scale, offset) -> UDimA dimension.
| Name | Type | Description |
|---|---|---|
scale | number | |
offset | number |
UDim
The fraction of the parent.
number
Pixels.
number
UDim2.new(xScale, xOffset, yScale, yOffset) -> UDim2From four numbers, or from two UDims: UDim2.new(x, y).
| Name | Type | Description |
|---|---|---|
xScale | number | |
xOffset | number | |
yScale | number | |
yOffset | number |
UDim2
UDim2.new(0.5, 0, 0, 20)UDim2.fromOffset(x, y) -> UDim2Pixels only.
| Name | Type | Description |
|---|---|---|
x | number | |
y | number |
UDim2
UDim2.fromScale(x, y) -> UDim2Scale only.
| Name | Type | Description |
|---|---|---|
x | number | |
y | number |
UDim2
The horizontal part.
UDim
The vertical part.
UDim
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.
Enum
if input.KeyCode == Enum.KeyCode.E then endPart materials (Plastic, Wood, Metal, Neon, ...), as RaycastResult.Material returns them.
Enum
Exclude and Include, for RaycastParams.FilterType.
Enum