Luduvo Contents
Theme
On this page

UDim2

UI positions and sizes that hold their layout when the viewport resizes

Constructors

1 member Access: shared

new(scaleX: number?, offsetX: number?, scaleY: number?, offsetY: number?) -> UDim2

make a 2d dimension of scale and offset

Parameters
NameTypeDescription
scaleXnumber?Fraction of the parent width.
offsetXnumber?Pixels added on the X axis.
scaleYnumber?Fraction of the parent height.
offsetYnumber?Pixels added on the Y axis.
returnsUDim2—

Positioning UI Elements with Scale and Offset

Lifecycle: Client

Each axis holds a fraction of the parent plus a pixel offset, so a layout survives a resize.

Luau
-- Centered horizontally and vertically with a 24px bottom offsetlocal centerBadge = UDim2.new(0.5, 0, 0.5, 24)-- Responsive size: 90% screen width minus 32px margins, fixed 64px heightlocal actionPanel = UDim2.new(0.9, -32, 0, 64)-- Offset arithmeticlocal shifted = centerBadge + UDim2.fromOffset(0, 12)