#How to click on a part that opens a GUI?
1 messages · Page 1 of 1 (latest)
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)```
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)
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
is this suppose to be a local script
I made it a local script
ok nice
why u making an if statment for the local player
that just makes it a boolean
idk. This is the code switch told me to put in
Still nothing
StarterPlayerScripts
It's called frame
the GUI is called poem
The GUI is enabled, the frame is not visible
So ScreenGui>poem>Frame
Yes
Is frame currently invisible
It is currently invisible
The GUI is enabled
If possible I would like that the other way around
But that's a me thing
If possible, I would like the GUI to be not enabled and the frame visible
** You are now Level 4! **
whichever one cuts down on lag more
thats not possible
Ok so
make gui.Visible = true
yes
Still doesn't work
whats error in output
It's a localscript. I thought localscripts don't show up on the output screen?
It doesn't show anything on the output screen
they do
or any of the script analysis screens
ah wait
"poem is not a valid member of Workspace"
That's weird
Bro what did u type
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
are there any errors in the console
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
Button.Activated would work better
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
nice
Weeks is crazy
I mean, I'm not much of a coder and I blindly trusted the tutorials lol