Why is my open & close GUI button not working?

I am trying to work on my inventory. However my open and close button will not work. Here is the script:

	script.Parent.Parent:WaitForChild("Pets").Visible = not script.Parent.Parent:WaitForChild("Pets").Visible
end)
1 Like

May you show us your whole script and not just a piece of it?

Alright. That was meant to be the full thing, but it has glitched, or maybe it got updated since I have not been on in a while.

This is the whole script. Yes, it is small. It is just for a open and close button for my inventory.

That still does not open/close the GUI.

Is it a local script?

Here is a new version of it:

local petsFrame = script.Parent.Parent:FindFirstChild("Pets")

script.Parent.MouseButton1Click:Connect(function()
petsFrame.Visible = not petsFrame.Visible
end)

Give that a go and see how it is.

2 Likes

Yes it is a local script. Also, I will try it. Thanks!

Try this?

script.Parent.MouseButton1Click:Connect(function()
    If script.Parent.Parent:WaitForChild("Pets").Visible == true then
          script.Parent.Parent:WaitForChild("Pets").Visible = false
    else
          script.Parent.Parent:WaitForChild("Pets").Visible = true
   end
end)
2 Likes

Also, should I change the petFrame just to ā€œPetsā€, since that is the name of it. I have been taking breaks from scripting, so I donā€™t really remember stuff.

Never mind, It works! Thank you!

1 Like

No need, since it is just a ā€˜nicknameā€™ for the pets frame.

No worries!

1 Like

Alright. Thank you!! Hope you have a good day/night!

1 Like

I figured out what was wrong with your own script, it looks like there was a typo in Connect.
You accidently put 3 nā€™s in Connect instead of 2.

2 Likes

Oh, must of been my keyboard, ahahha. Yeah sometimes some of my keys donā€™t respond, or sometimes duplicates themselves. Thanks for pointing that out! Appreciate it!

1 Like