How do I make it so a GUI button makes a GUI visibility false

You can write your topic however you want, but you need to answer these questions:
1.A GUI button that makes a GUI visibility false

  1. I have put this code in so far but it doesn’t work:
    onClick(function()

script.Parent.Play.StarterGui.Visible = false

print(“Done”)

print(“Correct”)

end

  1. I am looking for a solution.

Thanks for reading.

1 Like
onClick(function()
script.Parent.Player.StarterGui.Visible = false
print(“Done”)
print(“Correct”)
end

Try this. I think it is ‘player’ instead of ‘play’

1 Like

Hello, so I would like to point out that you are doing a couple things wrong here. Firstly you are not making functions correctly. The proper way to make a function would be making a local or global function. Function Example:

local function foo()
  -- Do something
end

Secondly, I do not see anywhere you made a variable for your GuiButton, which is key to what you are doing. Variable Example:

local Button =  -- Define Object

Thirdly, when you are calling on the StarterGui, whatever you do to it will not be replicated to your view since when you join, all GUI’s are replicated to your PlayerGui. Fourth, you seem to not have a MouseButton1Click event for your button. ButtonClick Example:

GuiButton.MouseButton1Click:Connect() -- Add the function that will do what you want inside of the parenthesis.
5 Likes

Thank you!, I only just started scripting so im learning new things.