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

How do I center a GUI? [closed]

Asked by 10 years ago

This question already has an answer here:

GUI not centering

Hi, I couldn't get my GUI to position to the center of the screen so that if there Window is minimised or maximised.

At the moment I have my GUI at the top of the screen, but I don't think it's positioned properly. My current GUI position is: {0.4, 0},{0, 0}.

Marked as Duplicate by Perci1 and BlueTaslem

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 10 years ago

Use the Scale value in the Position property to position the GUI to the center of your screen. Then, for other players, that GUI will be in around the same spot. The reason you don't want to use offset is because offset will make the GUI in the exact same position for everyone. So people with smaller screens might see the GUI in a really weird place.

0
How do I do that? BenHall4433 0 — 10y
0
I use the Gui Tweak plugin, http://www.roblox.com/GUI-Tweak-V1-1-item?id=144052484. bobafett3544 198 — 10y
0
Thanks. Do you think {0.45, 0},{0, 0} would be the middle? BenHall4433 0 — 10y
Ad
Log in to vote
0
Answered by
KarlXYZ 120
10 years ago

A GUI's position and size is represented using: (XScale, XOffset, YScale, YOffset)

If you want the GUI to be in the centre of the screen regardless of the screen size then you should use offsets.

If you had a Frame that had the size (0,500)(0,250), and you wanted that frame to be centred perfectly in the middle of a players screen, then you would have (0.5,-250)(0.5,-125) as the position of it.

You essentially half the offset value for each axis, make it a negative number and add 0.5 in the XScale and YScale values.

XScale and YScale both can change the appearance of a GUI depending on the size of the ROBLOX window on a player's client. You should only use XScale and YScale for size if you need a GUI to cover the whole player's screen. If you aren't, you should be using XOffset and YOffset which are basically pixels.

More examples of a centred GUI could be:

TextBox of size (0,50)(0,100), position would be (0.5,-25)(0.5,-50) ImageLabel of size (0,700)(0,300), position would be (0.5,-350)(0.5,-150)

Finally, always remember that a GUI's position and size is measured from the top left corner of any GUI element.