UDim
Roblox-style scale and offset pair.
Syntax
UDim.new(scale?: number, offset?: number) -> UDim
UDim.fromScale(scale?: number) -> UDim
UDim.fromOffset(offset?: number) -> UDim
Parameters
| Parameter | Type | Description |
|---|---|---|
scale | number | Scale component, default 0. |
offset | number | Offset component in pixels, default 0. |
Returns
| Type | Description |
|---|---|
UDim | The constructed value. |
Description
UDim.fromScale sets the offset to zero and UDim.fromOffset sets the scale to zero.
The userdata exposes read-only Scale and Offset numbers. typeof(udim) reports UDim and == compares both components exactly.
Example
local u = UDim.new(0.5, 10)
print(u.Scale, u.Offset, typeof(u))
print(UDim.fromOffset(24).Offset)
Notes
UDim2constructors still take raw numbers; building a UDim2 from a UDim is not implemented.- Arithmetic operators are not implemented.