Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isnt my button changing the visibility?

Hello I have a function here that opens a window perfectly fine and every click on the button checks to see if the window is open/closed. But when the window is open another click of the button will not close it.

local function openChar()
	if isCharOpen == false then
		script.Parent.RoundBoxChar.Visible = true
		script.Parent.upTriangleChar.Visible = true
		isCharOpen = true
	else
		script.Parent.RoundBoxChar.Visible = false
		script.Parent.upTriangleChar.Visible = false
		isCharOpen = false
	end

1 answer

Your issue might be the scope of isCharOpen. I'm also not sure if you forgot a part of your code or don't have your function closed, but it's fixed below. Putting a local isCharOpen = false ABOVE the function, in the global scope should fix the issue.

local isCharOpen = false

local function openChar()
    if not isCharOpen then
        script.Parent.RoundBoxChar.Visible = true
        script.Parent.upTriangleChar.Visible = true
        isCharOpen = true
    else
        script.Parent.RoundBoxChar.Visible = false
        script.Parent.upTriangleChar.Visible = false
        isCharOpen = false
    end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.