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

How would I make a GUI fit with Screen Resolution?

Asked by 8 years ago

So, Im scripting my GUI, and I want it to also fit with others screens so I wont get any PMs talking about the GUI not being in Place, How would I do this? I mean I tried the script.Parent.Postition = UDim2.new (1,0,1,0)

1 answer

Log in to vote
2
Answered by
unmiss 337 Moderation Voter
8 years ago

GUI objects (frames, textlabels, imagelabels, etc.) have to be positioned on your screen. There are two ways (which can be used interchangeably) to position a piece of your interface on the user's game. Assuming you know in a UDim2 there is two parts, which are in itself are two UDims. They are X and Y. X being horizontal placement and Y being vertical placement. Let's move on.

Offset

In UDim2.new(0, 50, 0, 90), 50 is the X and 90 is the Y. From the top left corner pixel of the GUI instance, it's position is 50 pixels to the right. and 90 pixels downward. In the same way, putting negatives behind them would make it 50 pixels to the left and 90 pixels upward.

Scale

In UDim2.new(1, 0, 1, 0) both of the coordinates are 1 in scale. The object would be placed on the bottom right corner of the interface, or object (if it is a child of another UI object).

Example

I have a frame that has a size of UDim2.new(0, 100, 0, 100) . To place it in the middle of the screen, I would put the Position property to UDim2.new(0.5, -50, 0.5, -50) . Essentially you are placing the top left of it in the middle of the screen with the two scales, and centering it by removing half of each coordinate. Try it out.

Another example. My frame size is UDim2.new(0, 200, 0, 30) . I want to place it in the very top right of the screen. I would put the Position property to UDim2.new(1, -200, 0, 0) .

Scale will make things exactly the same on all screens and sizes. Position only goes by absolute pixels, so if you placed something at UDim2.new(0, 1920, 0, 1080) on a 1080p screen, it would be in the bottom right of the object or ScreenGui.

Ad

Answer this question