Customclickdetector - A custom implementation of roblox's click detectors

customclickdetector

a custom implementation of roblox's click detectors
Wally - Github - Docs

Why?

The classic question. So through out all these years, Roblox had this instance called Click Detectors, we all know it. But, there were lots of issues with them; So I created this module. It uses raycasts for the customclickdetectors.

Demos

customclickdetector_buttonTest

Examples

Hello world.

local myClickDetector = customClickDetector.new({
    instance = workspace.Part
})
myClickDetector.mouseDown:Connect(function()
   print("Hello world")
end) -- event which when mouse is clicked, the function fires
customClickDetector.startLoop() -- starts the loop which handles the click detectors

Feedback appreciated.

17 Likes

image
.
Might be nice to have a bit more information xD
Interesting though! Roblox’s Click Detectors are pretty infamously bad.

1 Like

Could you explain what problems click detectors have and how your implementation is better?

3 Likes

Fine, I guess you kinda convinced me to use this over the default one. However, I think i’ll be sticking to ProximityPrompts though. Cool resource.

I forgor all of them :skull: my draft always threw a 403 error.

anyway, the most notable one is that its veryy hard to trigger roblox click detector while moving.

edit: ok i remembered one:
Not much events like mouseup.

1 Like

I would but I didn’t know what to put there.

Ill update it later.

is there an option to change the player’s mouse icon when hovering? like default clickdetectors?

Yes but its not documented yet. In the class add a hoverIcon key with the decal id.
note you can also add an unhoverIcon key to put the unhover icon decal id.

i just noticed the documentation has very little info.

But for now, all the table arguments are this:

instance = initialProps.instance,
            maxDistance = initialProps.maxDistance or 32,
            hoverIcon = initialProps.hoverIcon or "",
            unhoverIcon = initialProps.unhoverIcon or ""

So for a custom hover icon example, do this:

local myClickDetector = customClickDetector.new({
    instance = workspace.Part,
    hoverIcon = "rbxassetid://id"
})
myClickDetector.mouseDown:Connect(function()
   print("Hello world")
end) -- event which when mouse is clicked, the function fires
customClickDetector.startLoop() -- starts the loop which handles the click detectors
3 Likes

Hey, I can’t set up this module with wally, its this error

!EDIT, I figured it out.

You might want to drop the solution for any other users that encounter the same issue, unless you just did a dumb thing

Pretty cool, though I’d suggest you add more documentation for the less savy

Also, there’s some functionality problems where if your mouse leaves during a mouseDown, mouseUp never gets triggered.

This can be fixed if you adjust your code but just thought I’d let everyone know

Oops, will fix when I can

Hello, Do you mind releasing this as a RBXM or TOOLBOX MODEL.

There are also quite a few bugs.

I tried downloading the file from github and I have to go through lua files and figure out how its sorted.

This is how I ended up sorting it, It has loads of errors and random errors.
ClickDetector.rbxm (8.0 KB)

Thank you!

Hello, I might do this (If i even have enough motivation for this, i dont really visit this site anymore) but seeing people still use my resource despite me barely maintaining this is awesome. thanks guys

You can try using rojo and wally to sync it, then make it a model. Ill try to do it when I can though

Oh thank you for the directions, appreciate it.

I have never used rojo or wally so im not exactly sure how I would do this

You can clone my repo and then syncing it with rojo (as this tutorial will show you)