Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

GUI Center Position?

Whats the script for the center of the screen?

Thanks,

1 answer

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

6 comments

0

My GUI size is {0,600} {0,600} so what should the position be?

2

Just divide 600 by two, like he said. It's not hard at all.

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?

0

@Perci I did that. It ended up off screen.

0

Yeah it may have to be -300. Idk, I always just played around with the scale until it was close.

0

I edited my answer

This discussion is preserved as it was. New answers, comments, and votes are closed.