Need help scripting GUI

Hello, I’m Gofe09 and I have very little knowledge of scripting.

Ive made this main menu and already scripted the play button but I need help scripting the info button.

What I want/have

What I want it to do is when you click the info button the main menu GUI disappears then the Info GUI appears, then when you click the back button the info GUI disappears then the main menu appears again. I need help on what script I should use for example a local script or a script and what to write in it.

Pictures:



Explorer
Screenshot (12)

You use a local script for GUIs, local scripts are the only type of scripts that work for GUI because they’re client-sided, just like GUI is.

You just collect the GUI elements by defining them as variables and then setting their visibility to either true or false.

To detect if the info menu is open or not. you can also create a variable that you can use to determine if it’s open or not. Just set it as false at the beginning of your script.
Then whenever the player presses the button you can check if the variable is false or not and change the visibility and the variable’s value depending on it.

info button script

local info = script.Parent.Parent.Parent.Info -- or any path to the info, dont use startergui
local button = script.Parent

button.MouseButton1Click:Connect(function()
   info.Enabled = true
   script.Parent.Parent["Main Menu"].Enabled = false
end)

back button script

local mainmenu = script.Parent.Parent.Parent["Main Menu"] -- or any path to the main menu, dont use startergui
local button = script.Parent

button.MouseButton1Click:Connect(function()
   mainmenu.Enabled = true
   script.Parent.Parent["Info Gui"].Enabled = false
end)

Or just set it to :

nameofthegui.Enabled = not nameofthegui.Enabled

This way it sets the enabled property as the opposite of it so if it was false, it would set it to true.