ClickDetector extremely unreliable

I’m making a game and clicking mid-high speed objects is crucial in order for this game to work.
I have however noticed an issue with the ClickDetector which requires me to click hundreds of times on the object before it registers.
The only solution: Use an auto clicker, however this is not good for my players who might be on mobile or not have access to such autoclicker

Screenshot 2024-01-31 at 6.46.32 PM There isn’t much special other than a script inside it.

There’s really nothing to the script too

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

and it most certainly isn’t an issue with the script as far as I know.

In this video every time my cursor turns into the hand cursor I am actually clicking and it BARELY registers my clicks.

4 Likes

You should consider using raycasting instead as ClickDetector can become unreliable at high speeds (from my experience too)

1 Like

Yeah like @vxsqi said, ClickDetectors become fairly inaccurate with high speeds, along with DragDetectors.

You can check if the mouse’s .Target is a ball, which would be more accurate.

1 Like

Try this! It is a LocalScript in StarterPlayerScripts. The reason is the script needs the player’s mouse, which can only be accessed on the client or in a LocalScript.

local Ball = workspace:WaitForChild("Ball")

Ball.ClickDetector.MouseClick:Connect(function(Player)
	local Mouse = Player:GetMouse()
	
	if Mouse.Target.Name == "Ball" then
		Ball:Destroy()
	end
end)

Hope this helps! :slight_smile:

Did you even the read the post, or you just used AI?

ClickDetector won’t fire at high speeds thus that event will not work 100%.

It depends on the object size, create an invisible bigger part as a hitbox.

  • Use InputService and other services to create your own click detector.
  • Raycasts isn’t going to work for this type of games most likely.

Yes, I read the post. I wrote that code based off what @Katrist said and tried it. It worked for me, and I haven’t tried it with raycasts yet.

This should just be done with raycasts. Fire a ray, check if it hit, check if the instance it hit is one of your clickable objects

1 Like

That’s not what I said to do. You’re still using a ClickDetector, which defeats the whole purpose of checking mouse.Target.

Did you try it with high speeds though? The issue is not the code inside the function but the event not firing consistently.

1 Like