Close button not working

I was trying to make a GUI for my shop, though the script for the close button doesn’t seem to work properly. When you click it, it makes the close button UI go invisible, but not the entire GUI.

(I got the script of a YT tutorial, I’m not all that good at it myself.)

Images


Screen Shot 2020-11-10 at 3.38.43 PM

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

end)

Explorer:
Screen Shot 2020-11-10 at 3.45.51 PM

1 Like

Currently you are getting the CloseButton not the whole gui. I would get the GUI by saying.

game.Players.LocalPlayer.PlayerGui.MainGui.GamepassesGui

to get the whole UI to go invisible.

4 Likes

Alright. I assume that is a local reference.

That is because the script is making the CloseButton invisible and it looks like you intended to do just that. If you want the whole of the GamepassGui to be invisible you will need to define the GamepassGui and put its enabled property off:


local Player = game.Players.LocalPlayer
local GamepassGui = Player:WaitForChild("PlayerGui"):WaitForChild("MainGui"):WaitForChild("GamepassesGui")

script.Parent.MouseButton1Click:Connect(function()
    MainGui.Enabled = false -- simply disable the enabled property

end)

Thank you @SkyKurr, the script works now!

@Abroxus I finished up with the other fix as soon as you sent urs lol.

1 Like