Im not sure if this is scripting related but, how can I make a gui fit every screen? In games like Jailbreak and MM2, you can tell that their UI fits in every screen. When you rescale your screen, the ui gets smaller and still stays in the same position. How can I acheive this?
The size and position properties of gui elements are defined as values called UDim2
which stands for Universal Dimension. UDim2 values have four numbers. It has the x scale, x offset, y scale, and y offset. The x scale and y scale tells the percentage of the screen while the offsets tell the pixels. For example, the position UDim2.new(0.5 , 0 , 0.5 , 0)
would be exactly at the center of the screen no matter the size because we defined it to be fifty percent across and fifty percent down.
The position UDim2.new(0 , 230 , 0 , 40)
would be a position 230 pixels across and 40 pixels down. Because this is in pixels, it would position differently between different screens (different screens have different screen resolutions).
You do not need a script, you just have to use the Scale of the size and position