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

Keeping the same GUI positions with different resolutions?

I don't really have any code but I have 2 screen shots:

800x600: http://prntscr.com/av6dk0 1920x1080: http://prntscr.com/av6eac

How do I keep it so no matter the players resolution the gaps of the gui/textboxes will stay the same? I've seen it work on other games but not sure how to do it.

2 answers

✓ Accepted answer

You can do this with the x and y scale arguments of the datatype UDim2. These scale arguments must be in the range of 0 to 1 and represents a percentage of the screen width/height. UDim2 is constructed like:

UDim2.new(xScale, xOffset, yScale, yOffset)

So lets say you want to stick a GUI of size 100x100 in the bottom left corner. We can set the yScale to 1 (100% the height of the screen) and set the Offset to negative the height of the GUI:

local gui = ScreenGui.Frame

Frame.Size = UDim2.new(0, 100, 0, 100)
Frame.Position = UDim2.new(0, 0, 1, -100)

The problem inherent with using Scale positioning is that, although it keeps the guis in the correct percentage of the screen, it doesn't care about the position of any other gui -- often causing them to overlap.

Since you said in the chat that all three guis are inside a single Frame, we can use that to our advantage.

Position the Frame using Scale. This will put it in the correct position on everyone's screens.

Now position the other guis using Offset. The Offset will be relative to the Frame, since the guis are inside it, but because Offset uses pixels instead of percentages, it will keep them all the same number of pixels away from each other.

At least I think this should help.

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