Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.
UDim
The UDim data type represents a one-dimensional value with two components: a relative scale and an absolute offset in logical pixels. At evaluation time, the engine computes the final pixel value as Scale * referenceMeasurement + Offset, where the reference measurement is typically the size of a parent GuiObject along the corresponding axis.
UDim values appear individually in properties such as UICorner.CornerRadius, UIPadding.PaddingTop, and UIStroke.Thickness, or paired as a UDim2 for two-dimensional sizing and positioning.
-- 50% of the parent plus 10 extra logical pixels
local dimension = UDim.new(0.5, 10) Constructors
| Name | Type / Returns | Description |
|---|---|---|
| UDim.new | Returns a UDim from the given components. |
UDim.new
Returns a new UDim from the given Scale and Offset components. Both parameters are optional and default to 0 when omitted; calling UDim.new() with no arguments produces a UDim equivalent to UDim.new(0, 0).
local fullScale = UDim.new(1, 0) -- 100% of parent, no pixel offset
local fixedPixels = UDim.new(0, 200) -- 0% scale, 200 pixel offset
local mixed = UDim.new(0.5, 20) -- 50% of parent plus 20 pixels Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| Scale | number | The relative scale component, expressed as a fraction of the reference measurement (for example, 0.5 for 50% of the parent size along the corresponding axis). Defaults to 0. | |
| Offset | number | The absolute pixel offset added after the scale is applied. Stored as an integer. Defaults to 0. |
Properties
| Name | Type / Returns | Description |
|---|---|---|
| UDim.Scale | number | The relative scale component of the UDim. |
| UDim.Offset | number | The absolute offset component of the UDim. |
UDim.Scale
The relative scale component of the UDim, expressed as a fraction of a reference measurement (typically the corresponding axis of a parent GuiObject). A value of 1 represents the full reference measurement, 0.5 represents half, and 0 means the scale contributes nothing to the resolved pixel value. Defaults to 0 when not specified in the constructor. This property is read-only.
| Field | Value |
|---|---|
| type | number |
UDim.Offset
The absolute offset component of the UDim in pixels. This value is added to the resolved scale portion (Scale * referenceMeasurement) to produce the final pixel measurement. The offset is stored as an integer. Defaults to 0 when not specified in the constructor. This property is read-only.
| Field | Value |
|---|---|
| type | number |
Operators
| Name | Type / Returns | Description |
|---|---|---|
| + | UDim | Produces a UDim representing the sum of the two UDim values. |
| - | UDim | Produces a UDim representing the difference between the two UDim values. |
UDim + UDim (addition)
Produces a UDim whose Scale is the sum of the two operands' scales and whose Offset is the sum of their offsets. Each component is added independently: UDim.new(a.Scale + b.Scale, a.Offset + b.Offset).
| Field | Value |
|---|---|
| operation | + |
| type a | UDim |
| type b | UDim |
| return type | UDim |
UDim - UDim (subtraction)
Produces a UDim whose Scale is the difference of the two operands' scales and whose Offset is the difference of their offsets. Each component is subtracted independently: UDim.new(a.Scale - b.Scale, a.Offset - b.Offset).
| Field | Value |
|---|---|
| operation | - |
| type a | UDim |
| type b | UDim |
| return type | UDim |