Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ClickDetector script not working/code not running for some reason?

Asked by 3 years ago

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:

1print("Hello world!")
2script.parent.MouseClick:Connect(function()
3    print"hi"
4    game.LocalPlayer.PlayerGui.Frame.Visible = true
5end)
6workspace.buttonthing.ClickDetector.Parent.Mouse:Connect(onMouseClick)
0
hey, im not sure what youre having trouble on: likejagar 17 — 3y
0
the second line or the sixth line? likejagar 17 — 3y

4 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

This is how you can detect if you clicked on a certain part with the Script and ClickDetector

1script.Parent.ClickDetector.MouseClick:Connect(function()
2    -- code
3end)

The rest of the answers are all wrong

0
does not work. Absolutely no idea why. just does not respond to clicks danielminecrafter66 18 — 3y
0
nevermind, me being dumb ???? i had to put it in a server script danielminecrafter66 18 — 3y
Ad
Log in to vote
1
Answered by 3 years ago

Line 2 has a typo, it should be script.Parent

I would also remove line 6

1script.Parent.MouseClick:Connect(function()
2    print("hi")
3    game.LocalPlayer.PlayerGui.Frame.Visible = true
4end)
Log in to vote
1
Answered by 3 years ago

Hello.

I've found a few errors in your script, So I decided to help you,

  1. The Keyword: "Parent", Must start with Capitalized P (Line 2)

  2. You forgot to add the () Symbols after Print Keyword, Similar with Line 1. (Line 3)

  3. You got the "Connect" 2 Times, Just Erase the last line.

  • If I got something wrong, Please tell me what is the wrong because it's important.

Here's the Script:

1print("Hello world!")
2script.Parent.MouseClick:Connect(function()
3    print("hi")
4    game.LocalPlayer.PlayerGui.Frame.Visible = true
5       end
6end)

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.

1print("Hello world!")
2script.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
9end)
0
This does not work for some reason D: danielminecrafter66 18 — 3y
Log in to vote
0
Answered by 3 years ago

None of this works. Here is my new code:

1print("Hello world!")
2script.Parent.MouseClick:Connect(function()
3    print("hi")
4    game.LocalPlayer.StarterGui.ScreenGUI.Frame2.Visible = true
5end)

Answer this question