ClickDetector not registering clicks?

For some reason when I try using a click detector to detect clicks on a part, the clicks do not register.
I have my setup like this:
image
where Button is the child of a Model in the Workspace.
The click script is incredibly simple, just this:
image
To test if there was something wrong with the click detector, I checked for MouseHoverEnter events as well:
image
These did register, so I am wondering what I did wrong with the MouseClick event?


I should mention that there are no errors in the console, and the MaxDistance is set to 10,000,000,000 (10 trillion studs)

4 Likes

Are there any errors? 30 characters…

check maxDistance
300000000000000000000000000

No errors show in the console - nothing prints at all (other than “Hover”)

Max distance is set to quite high:
image

ohh you meant to do
script.Parent.MouseClick
not
script.Parent.ClickDetector.MouseClick

check if the script is disabled

image

It shouldn’t be disabled since the Mouse Hover events did fire

maybe the max distance is too high

That shouldn’t be the problem in theory and isn’t the problem in practice - I tried it at 32 studs when my character and player were right on the button part and still no results from the click event - only the hover event.

This is probably not gonna solve this, but try doing this:

local ClickDetector = script.Parent

ClickDetector.MouseClick:Connect(function(player)
    print("Click")
end)

Dunno whats the exact issue here, probably something internal issue? You might have restart or perhaps even reinstall it.

I tried clickdetectors and it worked for me

Import this model and see if it works or not
A ClickDetector Test.rbxm (2.7 KB)

1 Like

Your solution worked in a new Baseplate, however in the actual game place it didn’t. Im going to leave this topic open in hope that someone comes along and has an idea later, but thanks for the help.

Works totally fine for me.

Check the output for errors, and publish the place before testing.

Just note that if you have the MouseHoverEnter event inside your MouseClick event, it won’t fire until you activate the first event.

local part = script.Parent

local click = script.Parent.ClickDetector

function OnClick()

part:Destroy()

end

click.MouseClick:Connect(OnClick)

Just tested this in game and it works :slight_smile:

As I said in the post, there were no errors in the console. The place was published. And the MouseHoverEnter was connected in the global scope.

Its a rather big file, since its a whole game. I think I will just use GUI buttons in a ScreenGui rather than click detectors (for my usage it is possible to use either), but I do understand it is incredibly difficult to help someone when you don’t know the whole picture as some other things could be interfering. I am confident it is a place specific bug because ClickDetectors work in other game I have from the same code. Thanks for the offer to help though.

I Encourage you to change the parent of the script, for example from the click detector itself to the part and change your script to something like this:

script.Parent.ClickDetector.MouseClick:Connect(function()
print("TADA")
end)

I know this seems crazy but sometimes it works, I had this problem too but once i changed the parent it worked :open_mouth:

Hello @Quackers337,

Firstly is the “Button” part in another Part or Model? for example, it may not be Anchor and falls off the Part/Model.

Secondly, when you move the mouse over the “Button” part, does it change its texture?
image

So if the mouse doesn’t change texture it’s mean that it doesn’t detect the “Button” part, and if the mouse cannot detect the “Button” part it means that there is a Part or a GUI that is hiding it.

Could you check everything I said, and come back with answers thanks!