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

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

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

✓ Accepted answer

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.

1 comment

0

Thankyou

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