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

Image button isn't making my Frames visible to false?

Real quick, i never knew much about Lua and i'm trying to get back into it so i'm sorry if the answer is super simple i just can't think of whats wrong with it.

Frame = game.StarterGui.MaroonClickBait.Frame

script.Parent.MouseButton1Click:connect(function(plr)
	Frame.Visible = false
end)

The Parent of "script" is the image button, and the parent of the image button is the frame.

Also sorry for the weird title, it kept saying to make it brief but easy to understand and anything that made sense wouldn't work.

1 comment

0

Add a "print("something")" in the script to see if it's even run. If script outputs it then try placing it inside the function. (basic troubleshooting)

4 answers

✓ Accepted answer
Frame = --(say script.Parent until you reach starterGUI - starter Gui becomes PlayerGUI in game and is a child of the player.)

script.Parent.MouseButton1Click:connect(function()
    Frame.Visible = false
end)

for example if you had it like this :

-STARTERGUI --> MaroonClickBait --> Frame ("and") ScreenGui --> ImageButton --> LocalScript

you would do:

Frame = script.Parent.Parent.Parent.MaroonClickBait.Frame

script.Parent.MouseButton1Click:connect(function()
    Frame.Visible = false
end)
Frame.Visible = not Frame.Visible

is what I use to toggle visibility. then if there's additional functionality to it I often do

function toggleGui()
	gui.Visible = not gui.Visible
	if gui.Visible then
		--do stuff, like update the gui contents or something
	end
end

So basically what you'll want to do is use an If Statement to change the Frame's visibility to false. So your script:

Frame = game.StarterGui.MaroonClickBait.Frame

script.Parent.MouseButton1Click:connect(function(plr)

--add if statement

 if  Frame.Visible  ~= false then
    Frame.Visible = false 
 end
end)


--and I'm guessing you'll want to make it visible again when clicked so here it is

Frame = game.StarterGui.MaroonClickBait.Frame

script.Parent.MouseButton1Click:connect(function(plr)

--add else to if statement

 if  Frame.Visible  ~= false then
    Frame.Visible = false 
 elseif Frame.Visible == false then
	Frame.Visible = true
 end
end)

1 comment

0

Still doesn't work but still no errors.I even copied and pasted but that also didn't work. Not sure what the problem is

This also doesn't work.

function OnClick()
script.Parent.Parent.Visible = false
wait(0.5)
script.Parent.MouseButton1Click:connect(onClick)
end

1 comment

0

Edit your question for these purposes

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