Yuari
Documentation

UDim2

Roblox-style 2D scale and offset value.

Syntax

UDim2.new(xScale?, xOffset?, yScale?, yOffset?) -> UDim2
UDim2.fromScale(x?, y?) -> UDim2
UDim2.fromOffset(x?, y?) -> UDim2
UDim2(xScale?, xOffset?, yScale?, yOffset?) -> UDim2

Parameters

ParameterTypeDescription
xScalenumberHorizontal scale, default 0.
xOffsetnumberHorizontal offset in pixels, default 0.
yScalenumberVertical scale, default 0.
yOffsetnumberVertical offset in pixels, default 0.

Returns

TypeDescription
UDim2The constructed value.

Description

fromScale sets both offsets to zero; fromOffset sets both scales to zero.

The userdata exposes XScale, XOffset, YScale and YOffset. X, Y, Width and Height return tables with Scale and Offset fields.

Example

local size = UDim2.new(0.5, 0, 0, 120)
print(size.X.Scale, size.Y.Offset)
print(typeof(size))

Notes

  • typeof(UDim2.new()) reports UDim2.
  • Arithmetic operators are not implemented yet.
  • Generic GUI property writing is still required before assigning it to a real Instance.