Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 7 years ago
Edited 7 years ago

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.

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) kazeks123 195 — 7y

4 answers

Log in to vote
1
Answered by
phxtn 154
7 years ago
Edited 7 years ago
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)
Ad
Log in to vote
0
Answered by
Pejorem 164
7 years ago
Edited 7 years ago
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
Log in to vote
-1
Answered by
Radstar1 270 Moderation Voter
7 years ago

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)

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 Sniper2458 11 — 7y
Log in to vote
-1
Answered by 7 years ago

This also doesn't work.

function OnClick()
script.Parent.Parent.Visible = false
wait(0.5)
script.Parent.MouseButton1Click:connect(onClick)
end
0
Edit your question for these purposes Goulstem 8144 — 7y

Answer this question