I have no idea why, but for some reason, I have made a click detector script and it is not running the code. here is the code:
print("Hello world!") script.parent.MouseClick:Connect(function() print"hi" game.LocalPlayer.PlayerGui.Frame.Visible = true end) workspace.buttonthing.ClickDetector.Parent.Mouse:Connect(onMouseClick)
This is how you can detect if you clicked on a certain part with the Script and ClickDetector
script.Parent.ClickDetector.MouseClick:Connect(function() -- code end)
The rest of the answers are all wrong
Line 2 has a typo, it should be script.Parent
I would also remove line 6
script.Parent.MouseClick:Connect(function() print("hi") game.LocalPlayer.PlayerGui.Frame.Visible = true end)
Hello.
I've found a few errors in your script, So I decided to help you,
The Keyword: "Parent", Must start with Capitalized P (Line 2)
You forgot to add the () Symbols after Print Keyword, Similar with Line 1. (Line 3)
You got the "Connect" 2 Times, Just Erase the last line.
Here's the Script:
print("Hello world!") script.Parent.MouseClick:Connect(function() print("hi") game.LocalPlayer.PlayerGui.Frame.Visible = true end end)
It may have an Error, Because it doesn't detect if it's visible or not.
Or maybe I got it wrong...
So...
If you want the Close and Open Script, Which will work, I brought you one.
print("Hello world!") script.Parent.MouseClick:Connect(function() print("hi") if game.StarterGUI.ScreenGUI.Frame.Visible == false then game.StarterGUI.ScreenGUI.Frame.Visible = true else game.StarterGUI.ScreenGUI.Frame.Visible = false end end)
None of this works. Here is my new code:
print("Hello world!") script.Parent.MouseClick:Connect(function() print("hi") game.LocalPlayer.StarterGui.ScreenGUI.Frame2.Visible = true end)