New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

Why isn't my LOCAL script that toggles a gui on/off working?

Asked by 1 month ago

i'm making a gui that when you click a button it toggles another section of the gui on/off. here is the script

function leftClick(mouse)
    if script.Parent.Parent.DripColors.Visible == true then
        script.Parent.Parent.DripColors.Visible = false
    else
        script.Parent.Parent.DripColors.Visible = true
end
script.Parent.MouseButton1Click:connect(leftClick)
end

1). all the locations are correct 2). I've tried using :WaitForChild() 3). I've Looked on the internet everywhere for the answer 4). Now i am asking this website 5). Please Help

1 answer

Log in to vote
2
Answered by
sleazel 679 Moderation Voter
1 month ago

Seems like a silly mistake. Your event connection is declared inside the function. Function never runs, so the connection is never made. Please correct:

function leftClick(mouse)

    if script.Parent.Parent.DripColors.Visible == true then
        script.Parent.Parent.DripColors.Visible = false
    else
        script.Parent.Parent.DripColors.Visible = true
    end

end
--here this line needs to be outside function
script.Parent.MouseButton1Click:connect(leftClick)

I hope I helped.

0
Thankyou NSMascot 40 — 1mo
Ad

Answer this question