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

How do i make a Dissapearing Gui?

Asked by 9 years ago

I'm trying to have a script what makes the frame disappear when the button is clicked but it doesn't work. It doesn't work

 1 do button.MouseButton1Click:connect(function()
 2   frame.Visible = not frame.Visible
 3 end

when I press the button the frame just stay there.

Thanks but it says button and frame are unknown.

3 answers

Log in to vote
1
Answered by 9 years ago

Use the code blocks for code, and don't bother doing the line numbers. the code block does it for you.

Answer:

All Gui objects (except the Guis themselves) have a bool property called Visible. So:

button.MouseButton1Down:connect(function()
    frame.Visible = false
end) -- also, these types of functions have a ')' after the end

Also, you need to define everything (like the button) that you will use in the script.

Ad
Log in to vote
-1
Answered by 9 years ago

Answer : The button and the frame are not defined so

button = script.Parent --Make sure that the script is in the button
frame = script.Parent.Parent.FrameName --Replace the name of the frame here
button.MouseButton1Click:connect(function()
frame.Visible = false
end

If you would like it to reappear when they click it again, then

button = script.Parent
frame = script.Parent.Parent.FrameName -- Replace the name of the frame here
function onClicked()
if frame.Visible == true then
    frame.Visible = false
else
    frame.Visible = true
end
button.MouseButton1Click:connect(onClicked)

It's as easy as that

Log in to vote
-1
Answered by 9 years ago

Here:

local b=script.Parent
local fr=script.Parent.Parent.Frame -- Replace Frame with the Frame's name
b.MouseButton1Down:connect(function()
    fr.Visible=not fr.Visible
end)

Answer this question