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

GUI Button isn't closing my gui once I press it, no errors shown, what am i doing? [Answered]

Asked by 4 years ago
Edited 4 years ago

I'm trying to make a gui close button, no intentions to re-open it btw. I have the code and I even added a print to be sure where my mistake was and whenever I click the button nothing happens, yet I get no errors

game.StarterGui.ScreenGui.Frame.TextButton.MouseButton1Click:Connect(function()
        print("hi")
        game.StarterGui.ScreenGui.Frame.Visible = false
    end)

2 answers

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

The reason why it isn't working is because you're getting the ScreenGui from the StarterGui instead of the player's PlayerGui. Every player has a PlayerGui when they join a game and everything inside of StarterGui will replicate into their PlayerGui. You will need to get the player's PlayerGui and get the GUI's from in there and make changes to those for them to be able to see it.

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

The correct way to write your function would be:

script.Parent.MouseButton1Down:Connect(Function() game.StarterGui.ScreenGui.Frame.Visible = false end)

*Make sure to make this a local script and place it into the close button (Textbutton)

0
make sure the end) is on line 3 bulder251 26 — 4y
0
I tried using this yet it still didn't work, and yes I fixed the F in function and I made end) on line 3. ethhscool1 7 — 4y
0
Nvm, just had to do script.parent.parent:destroy() thanks for telling me about script.parent.mousebutton1down though :) ethhscool1 7 — 4y
0
No Problem, Good Luck! bulder251 26 — 4y

Answer this question