Why is ClickDetector not working?

I don’t know why, but at times the ClickDetector works, and then sometimes it doesn’t.

You can see the properties of it in the video, and they all seem right, so what’s going on? It doesn’t work with any other blocks either.

Mind showing the script in the part that contains as well the ClickDetector?

Sure, but remember that the ClickDetector isn’t working with ANY blocks, even ones with no script.
image


Another thing I’ve just discovered, it only appeared for a quick glance until it just disappears when I play.

The property ClickDetector only works if it is under a part!

Furthermore, I believe you coded wrongly too once creating the local function… Transfer the script to ClickDetector and do the following:

local Sensor = game.Workspace.Sensor1
local Puzzle = game.Workspace.CuP1
local Piece = game.Workspace.Cup2 -- Changing Cup1 to Cup2 for safety if the script confuses with the other object.
local ClickDetector = script.Parent

local function Appear()
    ClickDetector.MaxActivationDistance = 0 -- Distance of the Detector to click.
    Piece.Transparency = 1
    print(Piece.Transparency)

    task.wait(5)

    Sensor.Transparency = 0
    print(Sensor.Transparency)
    Sensor.CanCollide = false
    Sensor.CanTouch = false
end

ClickDetector.MouseClick:Connect(function(Appear)

Let me know if the code can work! :slightly_smiling_face:

Quick question, by saying the only way ClickDetector works is by putting it under a part, do you mean an actual part and not the cylinder I have in this example?

Cylinders, Trusses, Wedges, and others are just the type of shapes the part is going to have! You can eventually, change them (for short) through the Properties tab/in the script

I’m still not getting the cursor icon. I think Studio must be bugged for me, because absolutely no ClickDetectors work right now.

Publish the version of the place for both Roblox and Roblox Studio, and try restarting to see if it works

Before I had done that, I joined another game that I knew the script had worked on, and the icon didn’t show up but the script still worked. I think it’s possible that Roblox Studio just has a buggy icon for me.

Edit: If that is the case, then your script didn’t work.

Update:

The code certainly works, yet oddly, it appears that it is not detecting the cursor… Before entering the engine Roblox Studio, try disabling, temporarily, multiple plugins you have by following a guideline via the category #bug-reports. Later, analyse if the part can detect the cursor and/or if there are any errors through the Output tab.

If it is still encountering the issue, report to @Bug-Support while listing the reproduction steps, version of Roblox Studio, and other specific notes that you can take inspiration as seeing through Bug Report topics. As for a workaround, replace with a ProximityPrompt and in the script, replace the .MouseClick with .Triggered

I just tried your first recommendation, did not work. Might have to try the 2nd, and if it doesn’t work, report it.


Still nothing.

Debug statements

Okay, so I went to my Roblox Studio application to analyse the issue and found it… Basically, I accidentally wrote in the final lines a wrong part…

local Sensor = game.Workspace.Sensor1
local Puzzle = game.Workspace.CuP1
local Piece = game.Workspace.Cup2 -- Changing Cup1 to Cup2 for safety if the script confuses the other object.
local ClickDetector = script.Parent

local function Appear()
    ClickDetector.MaxActivationDistance = 0 -- Distance of the Detector to click.
    Piece.Transparency = 1
    print(Piece.Transparency)

    task.wait(5)

    Sensor.Transparency = 0
    print(Sensor.Transparency)
    Sensor.CanCollide = false
    Sensor.CanTouch = false
end

ClickDetector.MouseClick:Connect(function()
    Appear()
end)

I have checked both the Output tab and the scripts and it certainly works now! Here are my demonstrations:

Demonstration 1 (Using ClickDetector)

Demonstration 2 (Using ProximityPrompt)

Furthermore, to get the cursor icon in the context to change it, you would have to go to ClickDetector’s property and insert an ID of an image:

I apologise for the little mistake of mine there.

Yes, it worked! Thank you very much. And no need to apologize for the mistake, it happens.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.