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:

print("Hello world!")
script.parent.MouseClick:Connect(function()
    print"hi"
    game.LocalPlayer.PlayerGui.Frame.Visible = true
end)
workspace.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


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

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

script.Parent.MouseClick:Connect(function()
    print("hi")
    game.LocalPlayer.PlayerGui.Frame.Visible = true
end)
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:

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)
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:

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

Answer this question