Data types
Roblox-style value types implemented as VM userdata, with full operator overloading and typeof support. Includes Vector3, Vector2, Color3, CFrame, UDim2 and RaycastParams.
Vector3
| Member | Description |
Vector3.new(x?, y?, z?) | Constructor (also callable directly: Vector3(1,2,3)). Copy-constructs from another Vector3.
local v = Vector3.new(1, 2, 3)
print(v.X, v.Y, v.Z, v.Magnitude)
|
.X .Y .Z | Components (also lowercase). |
.Magnitude | Length of the vector. |
.Unit | Normalized copy (zero vector if length ≈ 0). |
:Dot(other) | Dot product.
local a = Vector3.new(1, 0, 0)
local b = Vector3.new(0, 1, 0)
print(a:Dot(b), a:Cross(b), a:Lerp(b, 0.5))
|
:Cross(other) | Cross product. |
:Lerp(other, alpha) | Linear interpolation. |
:Angle / :Min / :Max / :Floor / :Ceil / :Abs | Angle between vectors and component-wise helpers.
print(Vector3.new(1, 0, 0):Angle(Vector3.new(0, 1, 0)))
print(Vector3.new(-1.2, 2.7, 0):Floor())
|
| Operators | + - * /, unary -, == (* also accepts a scalar). |
| Constants | Vector3.zero, .one, .xAxis, .yAxis, .zAxis |
Vector2
| Member | Description |
Vector2.new(x?, y?) | Constructor.
local v = Vector2.new(100, 50)
print(v.X, v.Y)
|
.X .Y .Magnitude | Components and length. |
.Unit / :Lerp / :Dot / :Cross / -v / == | Unit vector, interpolation, products and operators.
local a = Vector2.new(3, 4)
print(a.Unit, a:Dot(Vector2.new(1, 0)))
|
| Operators | + - * /, unary -, == (* accepts a scalar). |
Color3
| Member | Description |
Color3.new(r?, g?, b?) | Components in 0–1 range.
local color = Color3.new(1, 0.5, 0.25)
print(color.R, color.G, color.B)
|
Color3.fromRGB(r, g, b) | Components in 0–255 range.
local color = Color3.fromRGB(255, 80, 40)
print(color:ToRGB())
|
Color3.fromHSV(h, s, v) | Hue, saturation and value in 0–1 range.
local color = Color3.fromHSV(0.58, 0.8, 1)
print(color.R, color.G, color.B)
|
.R .G .B | Components (also lowercase). |
:ToRGB() | Returns three integers 0–255. |
:Lerp(other, alpha) / :ToHSV() | Color interpolation and RGB→HSV conversion.
print(Color3.fromRGB(255, 0, 0):ToHSV()) -- 0, 1, 1
|
CFrame
| Member | Description |
CFrame.new(position?) | From a Vector3, three numbers, or empty (identity).
local cf = CFrame.new(Vector3.new(0, 5, 0))
print(cf.Position)
|
CFrame.lookAt(from, to) | Position + look-at rotation.
local cf = CFrame.lookAt(Vector3.new(0, 5, 0), Vector3.new(10, 5, 0))
print(cf.LookVector)
|
CFrame.Angles(x?, y?, z?) | Euler-angles rotation CFrame.
local cf = CFrame.Angles(0, math.rad(90), 0)
print(cf.LookVector)
|
.Position / .p | Position vector. .X .Y .Z also work. |
.LookVector .RightVector .UpVector | Rotation axes. .XVector, .YVector and .ZVector are aliases of the matrix columns. |
.Rotation | Copy with the position reset to zero. |
:PointToWorldSpace(v) / :PointToObjectSpace(v) | Coordinate-space conversion.
local cf = CFrame.new(10, 0, 0)
local world = cf:PointToWorldSpace(Vector3.new(1, 0, 0))
local object = cf:PointToObjectSpace(world)
print(world, object)
|
:ToEulerAnglesXYZ() | Euler angles.
local cf = CFrame.Angles(0, math.rad(45), 0)
print(cf:ToEulerAnglesXYZ())
|
CFrame.identity / fromAxisAngle / fromMatrix / fromEulerAnglesXYZ / fromEulerAnglesYXZ | Identity constant and rotation constructors.
local cf = CFrame.fromAxisAngle(Vector3.new(0, 1, 0), math.rad(90))
print(cf.LookVector.X)
|
:GetComponents / :Inverse / :Lerp / :ToWorldSpace / :ToObjectSpace / :ToOrientation / :ToAxisAngle | Matrix access, inversion, slerp interpolation, space conversion and rotation extraction, plus cf + Vector3 / cf - Vector3.
local cf = CFrame.new(10, 0, 0)
print(cf:Inverse().Position)
print((cf + Vector3.new(0, 2, 0)).Position)
|
| Operators | cf * Vector3 (transform point), cf * CFrame (compose), cf + Vector3 / cf - Vector3 (translate). |
UDim
| Member | Description |
UDim.new(scale?, offset?) | Scale/offset pair. UDim.fromScale(s) and UDim.fromOffset(o) fill the other component with zero.
local u = UDim.new(0.5, 10)
print(u.Scale, u.Offset, typeof(u))
|
.Scale .Offset | Read-only numeric components. |
UDim2
| Member | Description |
UDim2.new(xScale?, xOffset?, yScale?, yOffset?) | 2D position/size value. Also callable directly: UDim2(0.5, 0, 0.5, 0).
local size = UDim2.new(0.5, 0, 0, 120)
print(size.X.Scale, size.Y.Offset)
|
UDim2.fromScale(x?, y?) | Both offsets zero. |
UDim2.fromOffset(x?, y?) | Both scales zero. |
.XScale .XOffset .YScale .YOffset | Numeric components. |
.X .Y .Width .Height | UDim-style tables with Scale and Offset. |
RaycastParams
| Member | Description |
RaycastParams.new() | Creates a parameter table.
local params = RaycastParams.new()
params.FilterDescendantsInstances = { workspace.Model }
params.IgnoreWater = true
|
| Fields | FilterDescendantsInstances, FilterType, IgnoreWater, CollisionGroup, RespectCanCollide, BruteForceAllSlow |