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

When to use Offset and when to use Scale?

Asked by 7 years ago

So there are 2 factors (Whatever you call them), that can be used to change the size of the GUI, Offset and Scale.

My question is when is the best time to yous each?

1
I would recommend using both Scale and Offset when dealing with both Size and Position of GUI Objects. Depending on what you're trying to accomplish, you might want to have a Message GUI take up the majority of the screen however have a 10 pixel border. So the Size may be {1,-20,1,-20} and the position would be {0,10,0,10}. M39a9am3R 3210 — 7y
1
It just depends on what you're trying to accomplish. M39a9am3R 3210 — 7y

1 answer

Log in to vote
2
Answered by 7 years ago
Edited 7 years ago

Scale

Scaling a GUI keeps it in proportion to it's environment. Think of it like a tree, as a tree grows bigger, it's branches grow thicker and stronger in proportion to the size of the tree.


In the case of a GUI, it's environment would be your screen (or another GUI it's inside of). So as the parent of your GUI's size or position changes, the GUI that's scaled inside of it will continue to stay in proportion to it's parent.

Here's an example I whipped up, where the grey GUI is the scaled one, and the white GUI is it's parent that varies in size accordingly to the mouse's position: https://gyazo.com/414045c7f4221a4e3e4790d5cfff0a94

The exact size of the grey GUI in the above example is UDim2.new(0.5,0,0.5,0). Much like how Transparency and Reflectance works, scaling ranges from 0 - 1. 0 being 0%, and 1 being 100%. For example, something with the size of UDim2.new(1,0,1,0), will take up the width and height of the entire screen exactly by 100%.


Also notice that only the first number of each 2 numbers in UDim2.new function was given a value. This is because those specific arguments are the ones that get scaled. Here's a more detailed break down of how that works: http://prntscr.com/bp2r2j


Offset

Offset represents the absolute value of a GUI's size or position. If you have a GUI with a size offset of 50 X, that means that GUI will always be 50 pixels long no matter what - the environment has no effect on it. Here's an example of the same program from above, but with offset given for the grey GUI instead of scale: https://gyazo.com/dfa35a25430180d1cdf28ca9544119a6

The exact size of the grey GUI from above is UDim2.new(0,50,0,50). Notice only every second number is assigned a value, they're obviously the offset values.

Conclusion?

To actually answer your question, it really entirely depends on what you want to do. Here's a list I'd personally go by that just gives some examples of when to scale something vs when to offset it:

  • Scale

    • Making a fade in/out GUI that covers the entire screen

    • Making a chat system frame

    • Making a health bar

    • Making a GUI-based game with a screen window

  • Offset

    • Working with GUIs that the player can edit

    • Making a GUI that's size / position depends on mouse input

    • Making GUI particles effects

    • Changing the size / position of message logs

But those are just some random examples, you're not limited to them nor obligated to use them for these situations. Hope this helped, just let me know if you have any questions!

0
Thanks a lot! chill22518 145 — 7y
0
Not a problem! ScriptGuider 5640 — 7y
Ad

Answer this question