I have several guis in StarterGUI that each have a button that makes them visible on click. I want it so the player can only have one open at a time. However, even when I click on the buttons, I can still have all the guis open at the same time. Any tips?
local openBtn = script.Parent:WaitForChild("OpenListButton")
local badgeList = script.Parent:WaitForChild("BadgeListBackground")
local scrollingFrame = badgeList:WaitForChild("BadgeList")
local cooldown = false
local closed = false
local ShopGUI = game.StarterGui.ShopGUI:WaitForChild("ShopFrame")
local DonateGUI = game.StarterGui.DonateGUI:WaitForChild("DonateFrame")
local TpGUI = game.StarterGui.TPGUI:WaitForChild("Frame")
local badgeTemplate = script:WaitForChild("Badge")
badgeList.Visible = false
badgeList.Position = UDim2.new(0.5,0,-5,0)
openBtn.MouseButton1Click:Connect(function()
if DonateGUI.Visible == true then
DonateGUI.Visible = false
return
end
if ShopGUI.Visible == true then
ShopGUI.Visible = false
return
end
if TpGUI.Visible == true then
TpGUI.Visible = false
return
end
if cooldown == false then
cooldown = true
if closed == false then
closed = true
badgeList.Visible = not badgeList.Visible
badgeList:TweenPosition(
UDim2.new(0.5,0,0.5,0),
Enum.EasingDirection.InOut,
Enum.EasingStyle.Quad,
0.5,
false
)
wait(2)
cooldown = false
else
closed = false
badgeList:TweenPosition(
UDim2.new(0.5,0,-5,0),
Enum.EasingDirection.InOut,
Enum.EasingStyle.Quad,
0.5,
false
)
wait(1)
badgeList.Visible = false
wait(1)
cooldown = false
end
end