UI Visible script not operating properly

Hello Developer Forum!
Today while scripting UI I ran into the problem where when I pressed a button it was no longer showing the frame/window it was supposed to be. It was working before but am not quite sure what is causing the problem now. Below is the script that controls the UI buttons. Hope you guys can help and thanks for reading!

local replicatedStorage = game:GetService("ReplicatedStorage")

local starterRebirthAmount = 1000

local player = game.Players.LocalPlayer

local mainFrame = script.Parent:WaitForChild("MainFrame")

local rebirthMenu = mainFrame:WaitForChild("RebirthMenu")

local mainButton = script.Parent:WaitForChild("MainButton")

local rebirthButton = rebirthMenu:WaitForChild("RebirthButton")

local drinksToRebirth = rebirthMenu:WaitForChild("DrinksToRebirth")

local rebirths = player:WaitForChild("leaderstats").Rebirths

local menuButton = script.Parent:WaitForChild("MenuButton")

local menuFrame = script.Parent:WaitForChild("MenuFrame")

local serverStorage = game:GetService("ServerStorage")

local drinksFrame = script.Parent:WaitForChild("DrinksFrame")

local drinksButton = script.Parent:WaitForChild("DrinksButton")

local drinkMenu = drinksFrame:WaitForChild("DrinkMenu")

local drink1Equip = drinkMenu:WaitForChild("Drink1Equip")

local soda = serverStorage.Soda

mainButton.MouseButton1Click:Connect(function()

mainFrame.Visible = not mainFrame.Visible

end)

menuButton.MouseButton1Click:Connect(function()

menuFrame.Visible = not menuFrame.Visible

end)

drinksButton.MouseButton1Click:Connect(function()

drinksFrame.Visible = not drinksFrame.Visible

end)

Which bit won’t work correctly?

I am not quite sure, I believe it isn’t detecting when mousebutton1 is clicked.

So none of it works?

I have tried debugging but cant figure out what’s wrong.

Are you wanting the frames to be visible or to disappear on the click of the button?

Or do you want it to toggle on and off?

Read the reference on this it will show you examples of both:

https://developer.roblox.com/en-us/api-reference/property/GuiObject/Visible

1 Like

I want it to be able to toggle on and off using the button. I have resolved the issue, thank you all!

1 Like