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

How to center a GUI, GUI is different from studio and game?

Asked by 4 years ago

I need some help. I want to move a button to the bottom right of screen. I've been wanting to know how to center, move, and resize the GUI to wherever in the screen I want. But when I play the game the GUI is not in the place I put in studio.

0
GUIs may differ because there may be things like the Explorer, Output, etc. that are "squishing" the ' studio test canvas', making it differ from the actual canvas. Try switching to decimals (x, 0) from pixels (0, x) in UDim2, it can come in handy for support for different resolutions, like for example instead of using position (0, 700, 0, 250) to put it in the middle, use something like: (0.35,0, mudathir2007 157 — 4y
0
Consider turning your both offsets to 0, changing the size to something random, and resizing it from there s_iara 94 — 4y

3 answers

Log in to vote
1
Answered by 4 years ago

Use AnchorPoints

By default the AnchorPoint is at (0, 0) which is the top left.

Change the AnchorPoint to (0.5, 0.5) so it bases it off the middle of the Frame. Then set the position to UDim2.new(0.5, 0, 0.5, 0) to make the AnchorPoint be in the middle of the screen.

This means:

  • AnchorPoint is in the middle of the screen.

  • AnchorPoint is in the middle of the frame.

  • Therefore, GUI is exactly centered.

Ad
Log in to vote
0
Answered by
sheepposu 561 Moderation Voter
4 years ago

You have to be sure you are using the scale and not the offset. For example if I wanted to center a Frame that was 80% x 80%. I would do this Position = {0.1, 0}, {0.1, 0} Size = {0.8, 0}, {0.8, 0}

If I wanted a button in the bottom right that was 15% x 10% I would do this Position = {0.85, 0}, {0.9, 0} Size = {0.15, 0}, {0.1, 0}

I hope you get the concept now

Log in to vote
-1
Answered by
Rynappel 212 Moderation Voter
4 years ago

Well it really depends on the size. Try using this position I dont know if this will work though: {0.188, 0},{0.134, 0}

Answer this question