Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What is a UDim2 Value and how do I use it properly?

Asked by 4 years ago

Hellol I have not really known what a UDim2 value is, and I would like to try to understand it if possible. If possible, please explain what the parameters mean too.

1 answer

Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
4 years ago
Edited 4 years ago

UDim2 values are two sets of values, {Xs, Xo}, {Ys, Yo}.

They signify two things per set, scale and offset. Scale being a percentage of the viewport size, and offset being a pixel addend, used to offset the Scale if it isn't precise enough. Never strictly use offset unless you absolutely must, because it doesn't scale with the viewport.

An few examples would be, with a viewport size of 1920x1080, scale 0.5 on X would give you 1920/2x1080, or 960/1080; or something like with a viewport size of 1280x720, 0.254 scale on both X and Y would give you 1280*0.254x720*0.254.

0
If possible, what exactly is a viewport? And if I am correct, doing 0.5,0,0.5,0 would center the guiobject to the middle of the screen. ImNotKevPlayz 4 — 4y
0
Precisely. The viewport is just what you're viewing the game through, the camera. Fifkee 2017 — 4y
Ad

Answer this question