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:
1 | print ( "Hello world!" ) |
2 | script.parent.MouseClick:Connect( function () |
3 | print "hi" |
4 | game.LocalPlayer.PlayerGui.Frame.Visible = true |
5 | end ) |
6 | 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
1 | script.Parent.ClickDetector.MouseClick:Connect( function () |
2 | -- code |
3 | 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
1 | script.Parent.MouseClick:Connect( function () |
2 | print ( "hi" ) |
3 | game.LocalPlayer.PlayerGui.Frame.Visible = true |
4 | 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:
1 | print ( "Hello world!" ) |
2 | script.Parent.MouseClick:Connect( function () |
3 | print ( "hi" ) |
4 | game.LocalPlayer.PlayerGui.Frame.Visible = true |
5 | end |
6 | 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.
1 | print ( "Hello world!" ) |
2 | script.Parent.MouseClick:Connect( function () |
3 | print ( "hi" ) |
4 | if game.StarterGUI.ScreenGUI.Frame.Visible = = false then |
5 | game.StarterGUI.ScreenGUI.Frame.Visible = true |
6 | else |
7 | game.StarterGUI.ScreenGUI.Frame.Visible = false |
8 | end |
9 | end ) |
None of this works. Here is my new code:
1 | print ( "Hello world!" ) |
2 | script.Parent.MouseClick:Connect( function () |
3 | print ( "hi" ) |
4 | game.LocalPlayer.StarterGui.ScreenGUI.Frame 2. Visible = true |
5 | end ) |