Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Button that hides other UI's not working?

Asked by
Burobuu 18
4 years ago

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)
0
this is the worst build of a script gloveshun 119 — 4y
0
this is the worst build of a script gloveshun 119 — 4y
0
gloveshun im looking for help not your opinion on the "build of the script" Burobuu 18 — 4y

2 answers

Log in to vote
1
Answered by
IDKBlox 349 Moderation Voter
4 years ago

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!

0
After reading the first part twice I realized how that reversed what I already wanted to do- #OhThatMakesSense Burobuu 18 — 4y
0
lol, Glad I could help :) IDKBlox 349 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Try switching it to a local script if it's not already. It's worked for me multiple times before.

0
Unfortunately it already is one :( Burobuu 18 — 4y
0
:( User#25069 0 — 4y

Answer this question