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

Keeping size no matter screen resolution?

Asked by 7 years ago
Edited 7 years ago

So in my shop, I am trying to keep the same size, and when looking up how to keep the same aspect ratio, it changes the size and squishes all my items into a small space. But in Assassin, if you do that, it keeps its size.

My Shop: Sorry I didn't know how to import a GIF

Assassin: Link

Hope someone can answer my question! Thank You!

1 answer

Log in to vote
1
Answered by 7 years ago

Hey KingStared,

The reason why you keep encountering this 'problem' is because in Assassin the Size of the Guis is done by Offset however, the Position is done in Scale. Which is why, the Gui changes it's position when you resize the window however, it's size stays the same. For you to change your Gui's Size to Offset is quite simple.

Guis have Size and Position and these are UDim2 values. UDim2 values have 4 parameters in total. 2 of the first ones being 'X' and 'Y' and inside 'X' and 'Y' are 2 more properties: Scale and Offset. When you change the Scale of a Gui, that means that no matter how big or small the window becomes, the Gui will adjust accordingly however, with Offset the Gui keeps it's original coordinates and will not change it's Property no matter if you resize the window or not. So, you just have to change the Size properties of your Gui from Scale to Offset. By the way, I made a Java program a while back that changed Offset to Scale and vice-versa. I'll give you the equation to change from Scale to Offset.

For X Coordinate Changing of Scale to Offset

local max_pixels = 1439; -- The max amount of pixels. For me it's 1439 idk what it is for you might be the same but, I think it changes for each screen. Check yours by simply extending a Part's Size all the way and see when the opposite end of the Gui leaves the screen and that's how you find the max amount of pixels in the X coordinate.

local scale = -- This is the scale of the X coordinate of the Gui that you currently have.

local pixels = scale * max_pixels; -- This is the amount of pixels that your scale is. Just substitute this into your Gui's Size and erase the Scale of the X coordinate.

print(pixels)

For Y Coordinate Changing of Scale to Offset

local max_pixels = 610; -- The max amount of pixels in the Y coordinate. For me it's 610, might be different for you.

local scale = -- The scale of the Y coordinate of the Gui that you currently have.

local pixels = scale * max_pixels;  -- Yea, the formula is pretty much the same but, the maximum pixels for the Y coordinate on my screen is different then the X so I had to make 2 different functions to figure them out. Idk what yours is but, just substitute my max_pixels for yours.

print(pixels);

Well, I hope i helped and make sure you only change ur Size from Scale to Pixels and not your Position. Also, delete the Scale coordinate once you are done converting and you've set the Offset property accordingly.

~~ KingLoneCat

0
This works perfectly the only problem was how in Assassin it is always in the middle. When I did it with my shop both sides are not the same. KingStared 3 — 7y
0
Did you make sure to leave the Position Scaled and make the Size Offset? KingLoneCat 2642 — 7y
0
The size is just offset, is it bad that I am using offset and scale for my position? KingStared 3 — 7y
0
Yea, just use scale for your position. Only scale. KingLoneCat 2642 — 7y
View all comments (8 more)
0
I tried it an it still does the same thing. KingStared 3 — 7y
0
Position: {0.229, 0},{0.196, 0} Scale:{0, 700},{0, 400} KingStared 3 — 7y
0
By 'Scale' you mean Size? KingLoneCat 2642 — 7y
0
Oh, make sure the Position of the Guis inside of the Main Frame is not scaled. Make sure it's offset. KingLoneCat 2642 — 7y
0
Mess around with the Guis inside. Try out how their position will be in offset and their size in offset. KingLoneCat 2642 — 7y
0
So I did it offset for both scale and positon and it still is the same https://gyazo.com/27db2d993cfc4ad883af675e0477ded2 KingStared 3 — 7y
0
For the guis in the main frame KingStared 3 — 7y
0
Bump KingStared 3 — 7y
Ad

Answer this question