-
What do you want to achieve? Keep it simple and clear!
Making a Window Visibility Handler. If you open a GUI but another one is open, it will close and open the new one. If a GUI suddenly gets closed by a notification, it will open back when the notification is closed. -
What is the issue? Include screenshots / videos if possible!
It works, until you close the GUI. You can’t open it again until you open another GUI, and I can’t figure out how I would make the notification toggle -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I don’t really know what else I could try and I searched but couldn’t find anything.
Code:
local playerGui = game.Players.LocalPlayer.PlayerGui
local currentOpenGUI = script.current
local lastOpenedGUI = script.last
for i,v in pairs(playerGui:GetDescendants()) do
if v:IsA("TextButton") then
if playerGui:FindFirstChild(v.Name) then
v.MouseButton1Down:Connect(function()
playerGui[v.Name].Enabled = true
lastOpenedGUI.Value = currentOpenGUI.Value
if lastOpenedGUI.Value then
lastOpenedGUI.Value.Enabled = false
end
currentOpenGUI.Value = playerGui[v.Name]
end)
end
end
end