Why is my GUI close button not working?

So I’ve been making these gui open thingies and the close button on the first one works fine but the close button on the second one which is exactly the same doesn’t work for some reason.

As you can see the first close button works but the second one doesn’t.

This is the working close button script.

This is the non-working script.

Hello, is there an error in the output?

1 Like

Nope. I checked and there was nothing

Try:

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.Visible = false
    print("Set to false.")
end)

First off, try it in Roblox client. Sometimes Roblox errors for no reason. Second, let me know if it prints Set to false. , or even better, works then.

1 Like

Nothing happened, It just wouldn’t close and nothing printed

Btw when I click the open button it makes the frames enabled. Then when I click the close button its supposed to make the frames un-enabled

I don’t know if it works but, try to make a remote event when closing the gui

Where is the close button located? Is it in a frame or just in the ScreenGui?

2 questions.

  1. Can I see all the parents?
  2. Is the one you are trying to close a frame of a screengui ?

I never tried that script if its the same thing as one, well i did when i was new to scripting. But i only know thing when its just lots of script to do it.
If you close one gui with a server script. You won’t be able to close the the ui using client script because it’s already close to client but not in the server. And also in the first sentence i said,
I use while do and for do to get each buttons and put a function with it.
And to @47347cool you don’t really need to use a event when closing the ui because when you do, the ui is disabled in server, instead in the client.

if you show us all your parents for the second gui that would help to see whats wrong.

Instead of using this

script.Parent.Parent.Visible = false

Change it to this and remove the x button

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.Visible = not script.Parent.Parent.Visible
    print("opened or closed gui")
end)

That usually works for me

1 Like

I fixed it! Thank you all for your help!