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

Help to close a GUI through a script?

Asked by 4 years ago

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)
0
Sorry What Are You Trying To Do? Harry_TheKing1 325 — 4y
0
Is this in a local script? IStarConquestI 414 — 4y

2 answers

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

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

Ad
Log in to vote
0
Answered by
6zk8 95
4 years ago

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

Answer this question