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

Help to close a GUI through a script?

Hello, this script doesn't close the GUI can you tell me why?

local player = script.Parent.Parent.Parent.Parent.Parent
local Box = script.Parent.Parent.Parent.Frame -- get the GUI to close

local function buy()
	Box.Visible = false -- here the code doesn't hide the GUI
end

script.Parent.MouseButton1Down:connect(buy)

2 comments

0

Sorry What Are You Trying To Do?

0

Is this in a local script?

2 answers

Try This Maybe.

If Its A Frame You Want To Close Then Use This:

local Box = script.Parent.Parent.Parent.Frame -- I Copied Your Example

function buy() -- The Function
Box.Visible = false -- Make The Frame Invisible
end -- End The Function

script.Parent.MouseButton1Down:Connect(buy) -- When The Button Is Clicked Connect Function

OtherWise If You Want To Get Rid Of The GUI Then:

local Box = script.Parent.Parent.Parent.Frame -- I Copied Your Example

function buy() -- The Function
Box.Enabled = false -- Make The Gui Invisible
end -- End The Function

script.Parent.MouseButton1Down:Connect(buy) -- When The Button Is Clicked Connect Function

You Must Make Sure That Its A LocalScript Not A Normal Script.

If You Still Need Help You Can DM Me: Harry_TheKing1#2303

Here is my version:

local player = game.Players.LocalPlayer -- Easier way of getting the localplayer
local Box - script.Parent.Parent.Parent.Frame -- The path

--If you want to make the box visible here do the following : Box.Visible = true

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

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