I have a simple button that has only two functions, to enable the UI if it's already hidden, and to disable it like wise. The UI starts off already visible. The button and the other two it needs to change properties of are all under one screengui under the starter gui. I don't get any errors for it, it just wont work.
Le Script
script.Parent.MouseButton1Click:connect(function() if script.Parent.Parent.cashButton.Visible==true then script.Parent.Parent.cashButton.Visible=false end if script.Parent.Parent.cashButton.Visible==false then script.Parent.Parent.cashButton.Visible=true end if script.Parent.Parent.menuButton.Visible==true then script.Parent.Parent.menuButton.Visible=false end if script.Parent.Parent.menuButton.Visible==false then script.Parent.Parent.menuButton.Visible=true end wait(1) end)
Couple things Use ':Connect'; ':connect' is deprecated
Second I wasn't exactly sure what you were trying to do, So I'm hoping this is it..
Third, The way you have things are in this order:
if Cashbutton is visible then make it not visible end if Cashbutton is not visible then make it visible end
-- Therefor no matter what you do, It will always be visible lmao; same thing with the code below that menuButton thing
This is what you're going to want
local CashButton = script.Parent.Parent.cashButton -- Assigns the CashButton Variable local MenuButton = script.Parent.Parent.menuButton -- Assigns the MenuButton Variable -- I make the variables because it makes things look clean script.Parent.MouseButton1Click:Connect(function() -- Remember :connect is deprecated if CashButton.Visible == true then -- Checks if CashButton is visible CashButton.Visible = false -- if it is, then makes it not visible else -- Checks if CashButton is not visible CashButton.Visible = true -- If it's not, then makes it visible end -- ends it lol if MenuButton.Visible == true then -- Same thing here, Checks MenuButton MenuButton.Visible = false -- If visible, now it's not visible else -- Checks if MenuButton is not visible MenuButton.Visible = true -- If not, now it's visible end end)
If you have any questions (or I didn't answer your question) Let me know!
Try switching it to a local script if it's not already. It's worked for me multiple times before.