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

Why is this GUI distorted?

Asked by 9 years ago

I have created a GUI, but the only problem is this: when the user changes window size/if their screen size is larger or smaller, the GUI stretches. I have fixed my problem of having the position of it changing place when the screen size/window size is changed, but what about it being distorted? It stretches horizontally and I have no idea why.

1 answer

Log in to vote
1
Answered by
dyler3 1510 Moderation Voter
9 years ago

Updated

What Da Heck Is Causin Dis?

The reason this happens is that screen sizes have different Width:Length ratios. This means that one screen might have a W:L ratio of 1.5, while another may have a W:L ratio of 1.3.

So, let's apply this to a game. Let's say you have {.5,0},{.75,0} for a GUI's size. If my screen size was 1500 x 1000 then the GUI's AbsoluteSize would come out at 750 x 750. This would be a perfect square for my screen, but let's say we have the same on a screen with dimensions 1300 x 1000. This would make the GUI's AbsoluteSize come out at 650 x 750, therefore distorting the GUI.


Let's Fix It :P

So, to fix this issue, choose either the X or Y scale that you want to keep. Set the scale to whatever you want it to be, then insert one of the following scripts into it.

For A Set X Scale:

Scale=0.5 --Set this to whatever you want the scale to be (Any number above 0). Over 1 would have a larger Y size, and Less than 1 would have a larger X size.

Scale=1/Scale --Keep this the same

script.Parent.Size=UDim2.new(0 , script.Parent.AbsoluteSize.X , 0 , script.Parent.AbsoluteSize.X/Scale)

For A Set Y Scale:

local Scale=0.5 --Set this to whatever you want the scale to be (Any number above 0). Over 1 would have a larger X size, and Less than 1 would have a larger Y size.

Scale=1/Scale --Keep this the same

script.Parent.Size=UDim2.new(0 , script.Parent.AbsoluteSize.Y/Scale , 0 , script.Parent.AbsoluteSize.Y)

Anyways, if you did it correctly, it should work now. If you have any further questions/problems, please leave a comment below. Hope I helped :P

-Dyler3

0
I do in fact have a queston. When I set the size in the properties pannel to 0.1, it was a perfect size. But I went into the script and edited it the way you posted it and changed the ".5" to '0.1' but it made it LARGER than it should have been. Help? Tremelert 0 — 9y
0
Let me edit the script, and try it again. dyler3 1510 — 9y
Ad

Answer this question