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

GUI button to make "visible=false" a frame wont work?

Why this wont work?(i tried both local script and script)

function OnClicked()
	on = 1
	if on == 1 then
		on = 0
		script.Parent.Parent.Frame.Visible = false
	end
	if on == 0 then
		on = 1
		script.Parent.Parent.Frame.Visible = true
	end
	
end

script.Parent.MouseButton1Click:connect(OnClicked)

1 answer

✓ Accepted answer

Edited Ok I have it now, this should work. I just tested this in studio.

on = 1
script.Parent.MouseButton1Down:connect(function()
	if on == 1 then
		on = 0
		script.Parent.Parent.Frame.Visible = false
	elseif on == 0 then
		on = 1
		script.Parent.Parent.Frame.Visible = true
	end
end)

5 comments

0

dont work either

0

hmm let me try this in studio

0

huh, I just don't get it. Why would a generic function work rather than a regular one?

0

not sure why but it just works

0

It works because your "on" variable is being stored in your script environment rather than being reset every time the button is clicked.

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