#How to click on a part that opens a GUI?

1 messages · Page 1 of 1 (latest)

civic matrix
#

Hello. This seems like something that should be incredibly simple and I don't know what's wrong that is causing this to be so unbelievably difficult for me. I just want to click on a part and then open a gui. Every script I have found has either not worked or made some weird error. Is there anyone who could help?

#

Here are all the various attempts I have tried:

#

Doesn't open the gui:

local clickDetector = script.Parent:FindFirstChild("ClickDetector")

if clickDetector then
    clickDetector.MouseClick:Connect(function(player)
        local playerGui = player:FindFirstChild("PlayerGui")
        if playerGui then
            local gui = playerGui:FindFirstChild("paper")
            if gui then
                gui.Enabled = true
            end
        end
    end)
end```
Opens the gui but causes a bunch of strange errors due to it being a script, not a localscript:
```local clickdetector = script.parent.ClickDetector

clickdetector.MouseClick:Connect(function(plr)
    plr.PlayerGui:FindFirstChild("henry").Enabled = true
end)```
#

Perhaps it's a problem with my close button? Here is the code for that:

local GUI = Button.Parent.Parent

Button.MouseButton1Down:Connect(function()
    GUI.Enabled = not GUI.Enabled
end)```
bitter forge
# civic matrix Doesn't open the gui: ``` local Players = game:GetService("Players") local click...

hello! i assume this script is under the part, right? if its a localscript, it wont run in workspace. right now, this code makes the screengui itself visible, not the frame.

if you want it to work, try something like this in StarterCharacterScripts:

local part = workspace.Part -- replace with your part
local gui = game.Players.LocalPlayer:FindFirstChildOfClass("PlayerGui").ScreenGui.Frame -- replace with directory
local clickdetector = part:FindFirstChildOfClass("ClickDetector") -- assuming the clickdetector is under the part

clickdetector.MouseClick:Connect(function(plr)
  if plr == game.Players.LocalPlayer then
    gui.Visible = true
    -- or if you want it to toggle, "gui.Visible = not(gui.Visible)"
  end
end)
civic matrix
# bitter forge hello! i assume this script is under the part, right? if its a localscript, it w...

Hi! It didn't wor. This is the code I put in:

local gui = game.Players.LocalPlayer:FindFirstChildOfClass("PlayerGui").poem.Frame -- replace with directory
local clickdetector = part:FindFirstChildOfClass("ClickDetector") -- assuming the clickdetector is under the part

clickdetector.MouseClick:Connect(function(plr)
    if plr == game.Players.LocalPlayer then
        gui.Visible = not(gui.Visible)
        -- or if you want it to toggle, "gui.Visible = not(gui.Visible)"
    end
end)```
#

Do you need to define plr?

#

I clicked on the part, but nothing happened

hazy turret
civic matrix
hazy turret
#

ok nice

#

why u making an if statment for the local player

#

that just makes it a boolean

civic matrix
#

idk. This is the code switch told me to put in

hazy turret
#

remove that part

#

Where is the script at btw

civic matrix
#

Still nothing

civic matrix
hazy turret
#

wnats the part name

civic matrix
#

poem

#

all lowercase

hazy turret
#

Ok

#

whats the frame name u want to make visible

civic matrix
#

It's called frame

#

the GUI is called poem

#

The GUI is enabled, the frame is not visible

hazy turret
#

So ScreenGui>poem>Frame

civic matrix
#

Yes

hazy turret
#

Is frame currently invisible

civic matrix
#

It is currently invisible

#

The GUI is enabled

#

If possible I would like that the other way around

#

But that's a me thing

hazy turret
#

wdym the other way around

#

In fact take a screenshot of startergui

civic matrix
#

and here is poem (part)

hazy turret
#

Ok u confused me

#

okso

#

U want to make gui enabled?

#

or frame visible

civic matrix
#

If possible, I would like the GUI to be not enabled and the frame visible

tender sentinelBOT
#

studio** You are now Level 4! **studio

civic matrix
#

whichever one cuts down on lag more

civic matrix
#

if GUI enabled, frame invisible lags less, that's fine

#

Anyways, it's not important

hazy turret
#

Ok so

civic matrix
#

?

#

Replace gui.visible = not (gui.visible) with gui.Visible = true?

hazy turret
#

yes

civic matrix
#

Still doesn't work

hazy turret
#

whats error in output

civic matrix
#

It's a localscript. I thought localscripts don't show up on the output screen?

#

It doesn't show anything on the output screen

hazy turret
#

they do

civic matrix
#

or any of the script analysis screens

#

ah wait

#

"poem is not a valid member of Workspace"

#

That's weird

hazy turret
#

oh

#

do workspace:Waitforchild poem

civic matrix
#

ah

#

"WaitForChild is not a valid member of workspace"

#

some sort of typo

hazy turret
#

Bro what did u type

civic matrix
#

ah

#

It works!

hazy turret
#

u typed “ah”

#

oh ok

civic matrix
#

god damn it

#

It has the same problem as the last script

#

If I click on it and then press the close button, I can't click on it again

bitter forge
#

are there any errors in the console

civic matrix
#

Open script:

local gui = game.Players.LocalPlayer:FindFirstChildOfClass("PlayerGui").poem.Frame -- replace with directory
local clickdetector = part:FindFirstChildOfClass("ClickDetector") -- assuming the clickdetector is under the part

clickdetector.MouseClick:Connect(function(plr)
    gui.Visible = true
    -- or if you want it to toggle, "gui.Visible = not(gui.Visible)"
end)```
Close script:
```local Button = script.Parent
local GUI = Button.Parent.Parent

Button.MouseButton1Down:Connect(function()
    GUI.Enabled = not GUI.Enabled
end)```
#

This problem has been persistent for a while now

#

it's probably some logic error

bitter forge
#

Button.Activated would work better

hazy turret
#

bro gui.visible = false

#

that’s all u gotta do

#

Wait is gui the poem

#

if it is keep it as enabled and make it to false

#

it will work

civic matrix
#

OK wait I think I've got it

#

YESSS

#

That problem has been killing me for weeks

bitter forge
#

nice

hazy turret
civic matrix