What is a good way to make a script "(if gui frame1.visible) is false then gui (frame2.visible) is true"?

Hi

I have in my gui 2 Frames. One main menu and one little menu. What is an effectiv way to make a script that does. If the main menu frame is closed then the mini menu appears. Its a little hard to explain.

thats the main menu

that is the mini menu “I add in the future on the icon text a icon”

nice regards
sebastian

1 Like
function closeMenu() -- fire this when the mainMenu closes (if you use a GuiButton, you could use GuiButton.Clicked to trigger the function)

    UI.MainFrame.Visible = false
    UI.MiniMenu.Visible = true
end

function openMenu() -- fire this whenever miniMenu is clicked on (rather than use a frame, use a GuiButton so that its easier for you.)
    UI.MainFrame.Visible = true
    UI.MiniMenu.Visible = false
end
2 Likes

This would make the MiniMenu invisible whenever the Visible value of the MainMenu changes.
You can just change the Visible value of the MainMenu now and the Changed event will fire:
If the MainMenu is not visible, it will make the MiniMenu visible.
If the MainMenu is visible, it will make the MiniMenu invisible.

I don’t know if that’s what you want.
Code:

local MainMenu = script.Parent
local MiniMenu = MainMenu.Parent.MiniMenu

MainMenu:GetPropertyChangedSignal("Visible"):Connect(function()
	if MainMenu.Visible == false then
		MiniMenu.Visible = true
	else
		--You can see the MainMenu, make the MiniMenu invisible
		MiniMenu.Visible = false
	end
end)

--Now you can just change the Visible value of the MainMenu
MiniMenu.MouseButton1Click:Connect(function()
	MainMenu.Visible = true
end)

If it doesn’t work, please just reply to this with the errormessage.

Probably iPantasticGuy’s solution is easier.

3 Likes