How to copy GUI Size

Hello Devs!

I am wondering how to copy GUI Size. I want to make GUI opening animation and GUIs have different size, so I want to get GUI Size. There is example:

Opened GUI size: {0.383, 0},{0.545, 0}
Close GUI size: {0,0},{0,0}

When I’m closing GUI, size is changed to 0
But when I’m opening GUI, size is still 0

You can simply store the size value, or store the UDim2 value of where you want it to go.

local SizeOfUI =, 0, 0.545, 0)
script.Parent.Size = SizeOfUI

Ye, but I want to make something like Menu with settings, codes, shop and I want to store their size to use it for opening gui.
Here is Module Script:

        info.OpenSize =,Scale, 0, frameToOpen.Size.Y.Scale, 0)
		frameToOpen.Size =,0,0,0)
1 Like

I noticed a few problems there:

  1. It looks like there’s a logic problem. “OpenSize” is set to whatever the current size is. This means that after you set the size to 0,0,0,0 the OpenSize gets set to whatever the current size is, which is 0. So it’ll stay 0.
  2. OpenSize isn’t stored as a variable - it doesn’t look like your script ever attempts to set the size back to OpenSize. It only ever sets the size to 0 on line 3.
  3. There’s a typo on “frameToOpen.Size.X,Scale” - you used a comma on “X,Scale” instead of typing “X.Scale”

The logic should look like this:

  1. Set a variable (I’m assuming that’s what OpenSize is intended to be?) to the current size.
    local OpenSize =, 0, frameToOpen.Size.Y.Scale, 0)
    Do this once at the top of the script so it doesn’t get reset to 0 every time.
  2. When a button is pressed to open the GUI, set the size to OpenSize.
  3. When a button is pressed to close the GUI, set it to 0,0,0,0.

This will work, but I don’t know that you need to do this. If you’re trying to just make a button that opens and closes your GUI, you can just toggle the Enabled or Visible properties of ScreenGUIs and UI objects. This is far simpler and does not require storing the size of your GUI.

Simply set FrameToOpen.Visible to not FrameToOpen.Visible. Since Visible is a boolean, you can do this to set it to the opposite of whatever it currently is. If it’s currently true, it becomes false, and if it’s currently false, it becomes true.

Hope this helps!


When its a variable, it’s the same problem.

I will show you module script in full version because Im little confused.

local animations = {}

local TS = game:GetService("TweenService")

local clickInfo = {
	lenght = 0.2,
	Style = Enum.EasingStyle.Sine,
	Direction = Enum.EasingDirection.Out,
	Size = 1.3,

function animations.Open(button, frameToOpen)
	if button:FindFirstChild("ClickCooldown").Value == false then
		button:FindFirstChild("ClickCooldown").Value = true
		local info = {}
		info.TweenInfo =
		info.OpenSize =, 0, frameToOpen.Size.Y.Scale, 0)
		frameToOpen.Size =,0,0,0)
		info.OpenTween = TS:Create(frameToOpen, info.TweenInfo, {Size = info.OpenSize, Visible = true})
		button:FindFirstChild("ClickCooldown").Value = false

return animations

I tried setting up a test place in Studio to test for bugs, and one thing I noticed is that this will not work with frames which use “Offset” as a frame with the default size ({0, 100},{0, 100}) will be set to 0,0,0,0. I decided to modify your script slightly to account for Offset:

info.OpenSize =, frameToOpen.Size.X.Offset, frameToOpen.Size.Y.Scale, frameToOpen.Size.Y.Offset)

When I tested with that, the Output window correctly printed the following:

  13:00:28.122  {0, 100}, {0, 100}  -  Client - ModuleScript:25
  13:00:28.122  {0, 0}, {0, 0}  -  Client - ModuleScript:27

It looks like it should be working. It animated rather quickly, but it looked like it worked as you intended. However, the frame I tested with was already open and visible and on the screen before I ran the “Open” function of the module. “info.OpenSize” is checked and printed immediately before your script sets the size to 0,0,0,0 and then opens it back up with a tween animation.

I don’t know if this is something that was done intentionally for testing purposes or if it could be the source of some problems, so I just wanted to point that out just in case. I’m assuming this is just for testing purposes because, as I mentioned in my previous reply, your script overwrites “OpenSize” every time you run the Open function. This means that after you close it once, all future attempts to check the size will print 0,0,0,0.

Another solution could be this: As soon as you finish closing it and your size is 0,0,0,0, set “Visible” to false and set the size back to OpenSize. This means that your script will change the size back to what it was before you closed it, so you don’t lose the original size by overwriting it to 0.

If you’re still having any problems, please let me know & perhaps reiterate what you’re trying to achieve (what would the script do if it’s working as intended?) and what obstacles you’re facing (what isn’t working right?) and I’ll be sure to respond as soon as I’m available.

I also noticed that your script required that the button contains a BoolValue object to serve as the ClickCooldown. You could use a similar workaround by giving your frame two (or four if you wanna use offset) NumberValue objects, one which contains the original X value and another which contains the original Y value. These values will be read by the script and never overwritten. Then, if your frame is “closed” (size = to 0,0,0,0), you can tween back to the size stored in the NumberValues.

This certainly isn’t how I would do it, but I think you’d be able to implement it quickly and easily if all other options failed.

I tried a lot of methods but everytime the size is 0. I will use NumberValue method because only this method works. Maybe I’m doing something wrong.