Close GUI script not working

I am trying to make a close gui button but its not working

But its returning an error

I renamed the Frame as
DevForum error 6

Please help it would help my game progress further

Thanks

1 Like

Try to put in the variable: script.Parent.Close

Also if you can send a full screenshot of the explorer.

Sure

In which variable should I put in?

Show your explorer.

character limit

Include the full directory and the ancestory of the ScreenGUI. It will then let us help you better.

Hi, try putting that in the frame variable and check if it works.

i see the error text


script.Parent.Parent.Parent.Close

so change your local frame = script.Parent.Parent.Close to local frame = script.Parent.Parent.Parent.Close

1 Like

Fin let me check it and check if it works

Hello, the problem is that you’re putting an extra .Close on the variable, btw I would recommend doing it in this way:

local Frame = script.Parent.Parent
local Button = script.Parent

Button.MouseButton1Up:Connect(function()
    Frame.Visible = not Frame.Visible
end)

But @Eternity_Devs suggested to put another parent in the line

So which should I try?

Try Sarchyx’s method. It will work.

1 Like

I tried to do it his way and it worked

Both are correct, but it’s completely useless to use .Parent.Close because it will just go to its parent and then go back.

Yep It worked Thanks for the help

Do you know the difference between the both

Mark Sarchyx’s post as the solution.

personally I would do it like this

local Button = script.Parent
local Frame = Button.Parent

doesn’t have any repeated code

1 Like

The one Sarchyx posted would, if you were to have another error or not, be easier to understand and would remove some code.

Let me try that and see if it works