Make a GUI fit in every device

I’m not sure if this is supposed to be in scripting support, if its not my bad.

So, I saw a few tutorials about using a plug in to make a GUI fit in every device, but non of the methods work for me. Can someone tell me an efficient way to this?

I won’t mind if you tell me how to use the plugin*

GUI objects sizes are UDim2. They are like Vector2, but instead they have a scale and offset. Scale means it scales with the device. Offset is measured in pixels.

Yea, but how do I make the GUI fit in every device?

UDim2.new({ScaleX, OffsetX}, {ScaleY, OffsetY}) -- (You don't have to add the curly brackets.)

An example would be 0.5 as half of the screen in any axis.

But once I change it to 0.5, how do I resize it? Also, after making it 0.5 it still doesn’t fit on every device.

Are you using UDim2.new(0.5, 0, 0.5, 0)?

Wait, do I make that the position, size or what

Make that the size to be half in X and Y screen size.

Wait actually, it does fit mb. But, how do I change the size?

Just change the scale. Scale is measured in screen size, so if you put 1, it will take the whole screen up on that axes.

You can select the GUI in your explorer and run this code on the Run Command line:

for _,v in pairs(game:GetService("Selection"):Get()[1]:GetDescendants()) do if not v:IsA("GuiObject") then print("g") continue end  local x = v.Parent:IsA("GuiObject") and v.AbsoluteSize.X/v.Parent.AbsoluteSize.X or v.AbsoluteSize.X/workspace.CurrentCamera.ViewportSize.X local y = v.Parent:IsA("GuiObject") and v.AbsoluteSize.Y/v.Parent.AbsoluteSize.Y or v.AbsoluteSize.Y/workspace.CurrentCamera.ViewportSize.Y v.Size = UDim2.fromScale(x,y) end

This will set all the GUIObjects within the GUIBase to Scaled values, meaning it would fit in all devices.

My recommendation would be to set the frame that holds everything in it’s size to scale (instead of something like (0, 60, 0, 200) to (0.1, 0, 0.4, 0)). You can automate this process using this lovely extension (AutoScale Lite - Roblox).

Also, to make it have the same sort of shape no matter the screen size, click the “Add Constraint” button.

I think I get it a bit now, thanks. Just wondering, how do I make the text buttons and labels fit? Do I do the same thing?

My bad. Size is actually measured in the parent’s size. If you put the label in a frame, it will scale with the size of the frame. If you put it in a screen gui, then it will scale with the screen

1 Like

So for text buttons and labels, as long as the frame fits in every device the text of the buttons and stuff will fit right?

There is a property called SizeConstraint. This property allows the size of the Gui dependent on either their own axes, Y axis or X axis.

RelativeXY means the Size.X of the Gui will be depending on the screen’s X axis, same goes for Size.Y on the screen’s Y axis.

RelativeXX means both the Size.X and Size.Y of the Gui will be depending on the X axis of the screen. RelativeYY is the same except it’s depending the Y axis of the screen.

This only works if you are adjusting the Scale property, and not the Offset, because Offset is about specific pixels.