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

ClickDetector not detecting clicks?

Asked by 6 years ago
Edited 6 years ago
local cd = script.Parent:WaitForChild('ClickDetector')

cd.MouseClick:connect(function(playerWhoClicked)
    print(playerWhoClicked)
end)

There is a click detector in the script parent? I've tried the remote event thing to and it doesn't work can someone help please.

EDIT: It seems as its camera based, when the camera faces the brick in a certain way it displays the "click icon"

0
Anything in the output? theCJarmy7 1293 — 6y
0
Nothing at all jean1398reborn -5 — 6y

2 answers

Log in to vote
0
Answered by
Nep_Ryker 131
6 years ago

Try this:

local cd = script.Parent:WaitForChild('ClickDetector')

cd.MouseClick:connect(function()
    print("Clicked")
end)

It should print out Clicked. If it doesn't then I don't know xd

0
that is exactly what he did except he is trying to print the players name :/ greatneil80 2647 — 6y
0
Should've told he was using a LocalScript.. Nep_Ryker 131 — 6y
Ad
Log in to vote
0
Answered by
zblox164 531 Moderation Voter
6 years ago

I went into Studio and ran your code and found your problem. Your code is fine but make sure you are NOT using a local script. I tried to run the code on a local script and nothing happened but when I used a normal script it worked perfectly fine. If it still does not work then you could try removing the WaitForChild function as shown below:

 local cd = script.Parent.ClickDetector

 script.Parent.ClickDetector.MouseClick:connect(function(playerWhoClicked)
    print(playerWhoClicked)
 end)

Hope this helps!

Answer this question