Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

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)

4 comments

0

make sure the end) is on line 3

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.

0

Nvm, just had to do script.parent.parent:destroy() thanks for telling me about script.parent.mousebutton1down though :)

0

No Problem, Good Luck!

This discussion is preserved as it was. New answers, comments, and votes are closed.