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

How to automatically adjust ScreenGUI?

Asked by 4 years ago

Okay, so I have some Text Buttons in my game and when I went on my phone to test my game, the buttons took up most of the screen. I have seen in other games that the buttons automatically scale themselves to fit the screen appropriately. I would just like to know how to adjust the buttons to the screen. Thanks in advance! :D

1 answer

Log in to vote
0
Answered by
Benbebop 1049 Moderation Voter
4 years ago
Edited 4 years ago

GUI uses UDim2 which is much different then something such as Vector2. The first parameter is the fixed X value (in pixels), while the second parameter is a value that will be multiplied by the screen’s resolution to get the X value. Repeated with the Y as well. If both parameters have numbers then the end result will be added together. This will allow the GUI to scale correctly with different resolutions. In the following examples the screen’s resolution is 1024x768.

Ex.

{0, 0.5},{0, 0.5}

This will output a Vector2 of 512x384 with the given resolution

{100, 0.5},{200, 0.5}

This will output a Vector2 of 612x584 with the given resolution

Ad

Answer this question