What is the second and fourth values in a UDim2 value?

So I know what the first and third values are in a UDim2 value but I never understood what the second and fourth values are. Could someone explain it to me? (Sorry if this is the wrong category)

1 Like

Do you understand the second value or do you not?

When in doubt, consult the roblox wiki (UDim2).

You’ve got an X and Y axis each with a value for scale and offset. Scale represents a percentage of your screen size (Ex: an xScale of 0.2 means the gui will take up 20% of your screen). If your screen gets bigger, it also gets bigger and vice versa.

Offset represents a fixed size. Unlike scale, it will not get bigger/smaller depending on your screen size.

How would using the offset be useful though?

Because offset uses the pixels of a screen, it can be useful in many different ways.

Thank you for the explanation but I think I need an example to fully grasp the concept.

This. If you want something set to a fixed size then use offset. Example could be the topbar icons, they don’t change in size as your screen does (granted, they are fairly small).

I use offset when using ScrollingFrames because for whatever reason roblox decided that children of scrolling frames would base their scale on the ScrollingFrame’s CanvasSize rather than actual Size.

A UDim2 is a pair of 2 UDims; one for the X axis and the other for the Y axis.
If you don’t know yet, a UDim contains a value for scale and offset.

First and third are scale. From 0 to 1, scale is how much of the parent you take up on that axis, with 1 being 100%.

Second and fourth values are the offset. This isn’t in percentage and 0 to 1, but rather the amount of pixels your gui will take up.

I always leave offset (2 and 4) as 0, as scale allows your gui to be dynamic and go with all resolutions, whereas offset does not scale effectively. Offset is much easier though and better for GUI practices.