User can only close main menu once then the return button vanishes forever

  1. What do you want to achieve?

I want to add this new feature to the project I’m working on where the player can leave the main menu GUI to play the game without a GUI covering the screen.

  1. What is the issue?

When I close the GUI for the first time and open it up again it works fine, then I close it again and my return button vanishes forever even though it worked the first time.


before re-opening menu GUI


after re-opening menu GUI and then closing again to check if the button is still there

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve spent more than an hour debugging and it hasn’t been fixed. I checked solutions and didn’t find any that matched my situation where the “GUI opener button disappears”

Here’s the code for my button:

local smGUI = script.Parent.Parent.Parent
local smGUIFrame = smGUI:WaitForChild("smScreen")
local rtpButton = script.Parent

-- Eventually fix bug where you can only leave the menu once or the ui will be gone forever
script.Parent.MouseButton1Click:Connect(function()
	smGUIFrame.Visible = true
	rtpButton.Visible = false
end)

Here’s my hierarchy in case that’s what is causing the issue with this script:

I can’t figure out what’s wrong with my script as it’s a generic script I’ve used for every other button in my game and it’s been working out great so far until now.

Please help me find what’s wrong with my code and either explain how I can fix it or please show me the updated code that will solve this bug.

I would be very happy to have your help! Thank you!

2 Likes

this will set your button visibility to false and you never set the visibility to true which is why it can only function once. You might want to set up a seperate button for closing and opening the main menu. Unless you already have one check if the closing menu button sets this button’s visibility to true

1 Like

Thank you so much for pointing that out to me that I could use my other button to set the visibility to true for the return button.

I changed the Menu escape button’s code to make the button visible when clicked and now it works perfectly.

It was such a simple fix and yet I was stumped.

At least now I get to work on the more important features of this game. Thanks again!

1 Like

No problem I also suffer from a bad case of tunnel vision good luck!

1 Like