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

GUI Center Position?

Asked by 10 years ago

Whats the script for the center of the screen?

Thanks,

1 answer

Log in to vote
4
Answered by 10 years ago

The position property of a guiobject has a "Scale" Property. This scale property ranges from 0-1 (Though it can be used at any other number too), which is useful because it sizes or positions a guiobject based on the parent's size or position. If the guiobject is in a screengui, and it's not a child of anything other than said screengui, setting the scale from 0-1 will result in re-sizing / re-positioning the guiobject according to the screen dimensions. If you set the position of the guiobject to {0.5,0},{0.5,0}, the upper-left hand corner of the guiobject will be in the center of the screen. To place the gui in the center of the screen, just set the offset property as half the absolute size of the gui, like this:

{0.5, -GUI_SIZE_X / 2}, {0.5, -GUI_SIZE_Y / 2}

This should keep your gui in the center of the screen.

Hope this helped!

EDIT

The GUI_SIZE values are supposed to be negative. My bad

0
My GUI size is {0,600} {0,600} so what should the position be? Realixty 0 — 10y
2
Just divide 600 by two, like he said. It's not hard at all. Perci1 4988 — 10y
0
Isn't the offset position of X and Y supposed to be the negative of the X size of the GUI divided by 2 and the negative of the Y size of the GUI divided by 2? Spongocardo 1991 — 10y
0
@Perci I did that. It ended up off screen. Realixty 0 — 10y
View all comments (2 more)
0
Yeah it may have to be -300. Idk, I always just played around with the scale until it was close. Perci1 4988 — 10y
0
I edited my answer TurboFusion 1821 — 10y
Ad

Answer this question