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

How to perfectly position a GUI on all screens?

Asked by
Detzky 0
7 years ago

I am currently researching how to do it but with no luck, I am trying to have the whole screen be a gui with little buttons and such around it, this is what I am inserting to my TextButton's and Text labels.

script.Parent.Position = UDim2.new(0, 0 - (script.Parent.Size.X.Offset / 2), 0, 0 - (script.Parent.Size.Y.Offset / 2))

To help position it right, but even so it still shows up different on different screens, please help!

3 answers

Log in to vote
2
Answered by 7 years ago
Edited 7 years ago

What's the problem

You use Offset, that only changes the amount of Pixels it moves. Scale moves the gui and changes the gui's shape based on screen size.


Final Product

script.Parent.Position = UDim2.new(0-(script.Parent.Size.X.Scale/2), 0-(script.Parent.Size.Y.Offset/2),0)
--I don't understand what your script is for, just remember to use scale if you want to compensate for screen size


Hope it helps!

0
Thanks! Detzky 0 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

The simple answer is to use scale rather than offset. There are in fact very few cases where you should use offset.

Scale (the first number) is really simple to understand: a value of 0 represents the left of the screen on the X axis or the top of the screen on the Y. A value of 1 represents the right of the screen on the X axis or the bottom of the screen on the Y axis. Therefore, a value of 0.5 is halfway across screen, for example.

Scale will always take up the same portion of the screen no matter what size the screen is, making it preferred over offset.

0
You need to say, that if you do a scale of 0.5, then the gui wouldn't be directly in the center, but instead the left side would be. If you were to do UDim2.new(0.5,0,0.5,0) then the top left corner would be centered. EzraNehemiah_TF2 3552 — 7y
0
You'd need to use this equation: UDim2.new(0.5,-Gui.Position.X.Offset/2,0.5,-Gui.Position.Y.Offset/2) EzraNehemiah_TF2 3552 — 7y
0
Thanks for the quick answer! :) Detzky 0 — 7y
Log in to vote
0
Answered by 7 years ago

https://www.youtube.com/watch?v=k8NP-dqByp4

This video should help!

Answer this question