Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

2 comments

0

hey, im not sure what youre having trouble on:

0

the second line or the sixth line?

4 answers

✓ Accepted answer

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

2 comments

0

does not work. Absolutely no idea why. just does not respond to clicks

0

nevermind, me being dumb ???? i had to put it in a server script

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,

  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)

1 comment

0

This does not work for some reason D:

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.