Whats the most simple way to keep a button or a frame in the middle of the screen in all platforms

Preferably no scripting, Will memorize this and use it for now on to whoever helps. Even AI messed it up even though this seems like a pretty simple question :question: Anyone know the way?

so the button is in the middle of the screen on pc, ps, mobile, ipad etc and even roblox studio if possible

1 Like

Make the AnchorPoint 0.5, 0.5
and Position {0.5, 0},{0.5, 0}

Setting AnchorPoint to 0.5, 0.5 makes the pivot of the GuiObject centered.


Setting Position to {0.5, 0},{0.5, 0} puts the GuiObject to the center of the Screen from the AnchorPoint.
Using Scale and not Offset is important because;

making this wouldn’t be possible because Offset uses pixels, so it doesn’t respect the ratio of the screen.

;
image

3 Likes

i did this and in roblox studio it went to the top corner of my screen so i tried it in roblox and the same thing, even more far from the middle. Top right corner lol

???

care to show the properties of the GuiObject?
@proturk_yt just gave you the most thorough explanation of centering something.

all you need to do is follow these two lines

And i literally did and it teleported far from the middle, Whats confusing to you haha

what are the properties the frame’s parent.
image

1 Like

Make sure to do the same with the parent GuiObjects, they take the base size as their parents.

1 Like

the parent of the frame is a textbutton and the textbuttons parent is a screenGui so like this: game.workspace.GamepassGUI.ImportantBtn.Frame

But i dont want the button wich is the parent of this frame, to be in the middle of the players screen

if you don’t want that, then it is probably best to separate them.
take the frame you are trying to center out and parent it under the ScreenGui instead of the TextButton.

1 Like

If you parent a centered frame(Frame) to a non-centered frame(ParentFrame), “Frame” will be on the center of their parent frame and not in the center of the screen because like I said it takes the parent as the base scale:


You would have to parent the frame to something that covers the whole screen of the device in order to make it centered respectively to the screen, that probably would be the ScreenGui itself instead of anything else because it represents the whole screen of the users device.

3 Likes

Thanks for the explenation, i think it should work perfectly now!

Thank you its clear why it didnt work now

1 Like