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

How to get a GUI to always tween to the middle of the screen?

Asked by 4 years ago

I have a GUI and I am using a tween to bring it onto the screen. I want my game to work on all devices but I have noticed that when I'm testing on my phone, half the GUI is off the screen. But on my PC, it is in the middle. I was just wondering if there is something that I can do to make it always be in the middle of the screen, whatever the device.

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

This is because of Offset. This property is used to calculate how far out of line the GUI Instance should go in it's vertices. This doesn't work within the boundaries of the actual screen size, however. For actual relative screen position, we use Scale. This is a ratio of the GUIs parent X-Y vertices, and it stands as a float from 0-1. If the GUI Instance happens to reside within a ScreenGui, it will give you the vertices of the user's monitor size,only if the GUI Instance is a direct child of it though, otherwise, for example let's say it was a child of a Frame Instance, it will inherit it's vertices.

To position it as centered, use .5 on each scale position property to have it be position half-and-half.

0
You can also use the device emulator in Studio to run GUI tests for different platform support. Ziffixture 6913 — 4y
1
It should also be pointed out that you should set AnchorPoint to .5, .5 as well, else you're going to have to negate half the size of the GUI to center it correctly. Azarth 3141 — 4y
Ad

Answer this question