Udim2
Overview
Description
UDim2
is a data type used in Roblox to define the size and position of UI elements. This value is calculated based on scale (fraction) and offset (pixel size). UDim2
is composed of two axes (X and Y) and is commonly used to set the size and position of UI elements in a flexible manner.
Properties
X
UDim
Specifies the value for the X-axis. This value consists of two parts (scale and offset) that determine the size or position of a UI element using a combination of proportion and specific pixel sizes.
Code Samples
Y
UDim
Specifies the value for the Y-axis. Similar to the X property, it uses scale and offset to determine the vertical size or position of a UI element.
Code Samples
Constructors
new
UDim2.new
is a constructor that creates a UDim2
object. It allows you to specify the scale and offset values for both the X and Y axes in detail to define the object.
Parameters
number
xScale
X-axis scale
number
xOffset
X-axis offset
number
yScale
Y-axis scale
number
yOffset
Y-axis offset
Return
UDim2
The newly created UDim2 object
Code Samples
Methods
Last updated