#GUI - Can not open GUI after closing it

1 messages · Page 1 of 1 (latest)

hybrid grail
#

Hi! This is probably an obvious mistake, but I am rather new to working with GUI. The way the script is meant to work is if you click on a part it opens up a gui (as if you are reading it). There is then a close button that allows you to close it. This part works, however, when you press the close button, you suddenly can't even click on any of the other parts nor open the guis. They all have click detectors, yet it doesn't give you the option to click on them, and when you click nothing happens. Here is my code below:
Code in the part with the click detector that opens the gui: (This is a regular script)


clickdetector.MouseClick:Connect(function(plr)
    plr.PlayerGui:FindFirstChild("henry").Enabled = true
end) ```
Code in the close button that closes the GUI: (This is a local script)
```local Button = script.Parent
local GUI = Button.Parent.Parent

Button.MouseButton1Down:Connect(function()
    if GUI.Enabled == true then
        GUI.Enabled = false
    else
        GUI.Enabled = true
    end
end)```
verbal pilot
#

it does the exact same thing in this context while also being more readable

verbal pilot
hybrid grail
verbal pilot
hybrid grail
#

the part script arbitartily is a script whereas the close script is arbitrarily a localscript, should I change it to make them both localscripts or scripts?

hybrid grail
verbal pilot
#

you should be able to just copy and paste it over

#

local clickdetector = script.parent.ClickDetector
local Player = game.Players.LocalPlayer
local PGui = Player.PlayerGui
local Henry = PGui:WaitForChild("henry")

clickdetector.MouseClick:Connect(function()
Henry.Enabled = true
end)

hybrid grail
#

hmmm

verbal pilot
hybrid grail
#

copying it from a script to a localscript seemed to make it stop working

verbal pilot
hybrid grail
#

still isn't working as a local script

verbal pilot
hybrid grail
#

yes

verbal pilot
#

what does the error say?

hybrid grail
#

When I click on it, nothing happens

dense lanceBOT
#

studio** You are now Level 2! **studio

hybrid grail
#

no output or anything

verbal pilot
#

oooh

#

give it like 5 seconds

#

when you load in

#

I put a wait statement to avoid errors while the GUI was loading in

hybrid grail
#

Still nothing

#

I'll try making it a regular script just to see if it makes it work

verbal pilot
#

I just changed it to be a wait statement

#

try that

hybrid grail
#

ok when I made it a regular script I get this as an error

#

17:15:20.207 Workspace.ChestofDrawers.Drawer.Part.Script:3: attempt to index nil with 'PlayerGui' - Server - Script:3
17:15:20.207 Stack Begin - Studio
17:15:20.207 Script 'Workspace.ChestofDrawers.Drawer.Part.Script', Line 3 - Studio - Script:3

#

(This is referring to the script)

verbal pilot
#

thats a local script exclusive

hybrid grail
#

It still doesn't work when it's a local script

#

it just doesn't give an error

verbal pilot
# hybrid grail it just doesn't give an error

you're using this one right?

local clickdetector = script.parent.ClickDetector
local Player = game.Players.LocalPlayer
local PGui = Player.PlayerGui
local Henry = PGui:WaitForChild("henry")

clickdetector.MouseClick:Connect(function()
Henry.Enabled = true
end)

hybrid grail
#

Yes

verbal pilot
#

local clickdetector = script.parent.ClickDetector
local Player = game.Players.LocalPlayer
local PGui = Player.PlayerGui
local Henry = PGui:WaitForChild("henry")

warn("Test 1")

clickdetector.MouseClick:Connect(function()
warn("Test 2")
Henry.Enabled = true
end)

verbal pilot
# hybrid grail Yes

tell me if both, neither, or only one of those warn statements goes through to your output

verbal pilot
hybrid grail
verbal pilot
verbal pilot
hybrid grail
#

I did

verbal pilot
hybrid grail
verbal pilot
#

I might have messed up the capitalizations

hybrid grail
verbal pilot
hybrid grail
#

Yes

#

The click detector seems to be working

#

But neither of the warnings went through

verbal pilot
#

are you joining in and then immediately clicking the part?

hybrid grail
#

No

#

It takes about 5 seconds for me to walk there

#

I can try waiting a little longer

verbal pilot
#

the GUI is in this folder correct?

hybrid grail
#

Yes

verbal pilot
#

both scripts are local scripts?

hybrid grail
#

Yes

verbal pilot
#

idk whats wrong with it then

#

is there a big red X or something that you have to click to close the GUI?

hybrid grail
#

Yes

#

It seemed to stop working the second I made it a local script

dense lanceBOT
#

studio** You are now Level 3! **studio

hybrid grail
#

even before I put in the new code

verbal pilot
#

idk what to do then

hybrid grail
#

Huh

#

OK

#

I noticed something weird

#

It only seems to not be able to open multiple times for some of them

dim wharf
#

solved?

hybrid grail
#

no

#

not yet

hybrid grail
#

This doesn't apply to the script on its own

#

I have no idea how this is happening and makes zero sense

hybrid grail
dim wharf
#

im thinking

hybrid grail
#

ok

serene sparrow
#

Local scripts don't run in workspace

#

*The ones that you normally create don't