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

So I am trying to make a open/close gui system but the button wont open it. Any help?

Asked by 4 years ago

Here is the code that doesn't work:

script.Parent.MouseButton1Click:Connect(function() script.Parent.Parent.Visible = true end)

And for some reason i get this error message:

23:40:45.655 - Visible is not a valid member of ScreenGui

Also i tested it and the close button does work for some reason but the open button does not here is the close code that does work:

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

1
try .Enabled greatneil80 2647 — 4y

2 answers

Log in to vote
0
Answered by
DesertusX 435 Moderation Voter
4 years ago

ScreenGui doesn't have a property called Visible. These are only for other GuiObjects such as TextButton, ImageLabel, etc.

If you are sure you want the ScreenGui to be invisible, use this script.

script.Parent.MouseButton1Click:Connect(function() 
    script.Parent.Parent.Enabled = true 
end)

It's not much different except that I changed Visible to Enabled.

Enabled is the property of the ScreenGui you are looking for.

Don't forget to accept this answer if I helped!

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

What makes you think that ScreenGui's have a property called Visible, they don't! Also for a GUI to appear, you don't set the screen GUI to visible, you set its descendants to visible! If you want a GUI to appear, the script is down below for you.

script.Parent.MouseButton1Click:Connect(function()
  script.Parent.Parent.Visible = true -- Assuming that you want a GUI to appear, not the ScreenGui it self
end)

Or if you want to the UI to close and open upon clicking, the script would be:

script.Parent.MouseButton1Click:Connect(function()
  script.Parent.Parent.Visible = not script.Parent.Parent.Visible -- Assuming that you want a GUI to appear, not the ScreenGui it self.
end)

Or just in case, you want the ScreenGui itself to disappear.

script.Parent.MouseButton1Click:Connect(function()
  script.Parent.Parent.Enabled = not script.Parent.Parent.Enabled -- Assuming that you want the ScreenGui to be disabled..
end)

Answer this question