Answered by
gskw 1046
5 years ago
There are two minor bugs in different places that cause the behaviour you're seeing. Firstly, we'll see why the Frame jumps to a different corner when being minimized. The issue can be found in the following line:
1 | Frame.Position = UDim 2. new( { 0.719 , 0 } , { 0.082 , 0 } ) |
In my personal opinion, Roblox should throw an error as it would make the mistake easier to catch. The code tries to pass two tables to UDim2.new()
, which expects either four integers to two UDim values. This results in a "zero" UDim2 being created. You could change the code to either one of the following lines to fix the issue:
1 | Frame.Position = UDim 2. new( 0.719 , 0 , 0.082 , 0 ) |
2 | Frame.Position = UDim 2. new(UDim.new( 0.719 , 0 ), UDim.new( 0.082 , 0 )) |
Now, why does the GUI not move when you size it up? This is simply because the sizing up code never sets the Frame's position. You probably want to place the following line in that block:
1 | Frame.Position = UDim 2. new( 0.344735265 , 0 , 0.215235725 , 0 ) |
Also, be aware that sizing up sets the text to "Minimize"
, while the if
condition checks if it's "minimize"
, in lowercase. More idiomatically, you could use a boolean variable to track whether the GUi is minimized, or disconnect and connect the event to a different function every time it's toggled.