If you only need this code once it might be worth it to just hardcore the Gui’s size.
Also, on a side note:
gui:WaitForChild("Frame").Visible = true
Since you already created a variable that waits for Frame, I believe you can just use it in the following lines instead of waiting for child again:
frame.Visible = true
Edit:
In case you want to offset the existing UDim2, perhaps the following may help:
After reading the docs for a bit, it looks like UDim2.fromScale() " Returns a new UDim2 with the given scale components and no offsets."
So, I’m not sure since I’m reading the docs and writing this from my phone so I can’t test it, but this might be the function you’re looking for: UDim2.fromOffset() “Returns a new UDim2 with the given offset components and no scales.”
I won’t be able to hardcore this- it needs to be used many times and at different intervals at random times. I know how to do that stuff just I don’t know why ROBLOX is putting the size as -10 on the X instead of negating 10 from the original number. (which is 200)
The reason is because it is executing that code more than once. You are mixing up scale sizes and offset sizes you need to pick one or the other. What your code is doing is taking the 200(a scale value), subtracting 10 for 190 but using that value as an offset value which you now just erased your scale values. If it runs a second time, which it clearly is, your scale value is 0 which when you subtract 10 becomes -10.
You either need to set appropriate scale values or set offset values to start with. When you have 200, 0, 50, 0 you are telling the frame to be 200 TIMES the X size of its parent and 50 TIMES the size of its parents Y size which doesn’t seem reasonable. If you really want to subtract 10 from the sizing you need to change the frame size to (0, 200, 0, 50) by default.
Just remember to put some debounce(or math.min on your new size) in your code or it will shrink quickly being called more than once.
It is because of the difference between Scale and Offset:
Scale is from 0 to 1, with 0 representing 0% and 1 representing 100%, so making a frame take up the whole screen is easy, you can do it by setting the X and Y scale values to 1. You do this through:
frame.Size = UDim2.fromScale(1, 1)
Offset is the number of pixels, between 0 and the width or height of the screen. So, in order to make a frame 100 pixels wide and 50 pixels tall, you do this:
frame.Size = UDim2.fromOffset(100, 50)
The issue is how you are accessing these values. In the image you have provided, both scale values are 0:
For example: {1, 50}, {2, 35}
Scale X is 1
Scale Y is 2
Offset X is 50
Offset Y is 35
So, the problem is is that the X Scale is set to 0, and 0 - 10 is -10. The way to fix it is by changing frame.Size.X.Scale - 10 to frame.Size.X.Offset - 10, but there are other problems with the code that I think are worth mentioning:
Personally, I would not recommend using Offset, because it is pixel-based and will be different sizes on, say, a 4K screen vs a 1080p screen.
You don’t need the extra braces, so:
Should be:
frame.Size.X.Offset - 10, 50
Don’t handle UI on the server! This will only cause unnecessary visual delay for the client and increase the server’s network traffic. Just handle this code on the client through a localscript.