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.
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)
This also doesn't work.
function OnClick() script.Parent.Parent.Visible = false wait(0.5) script.Parent.MouseButton1Click:connect(onClick) end