How does the code behind ClickDetectors work?

So I’ve been wondering how ClickDetectors work. I know how to use them and such, but how does the code behind them work?
I’m mostly confused on how it knows when someone clicks it. The server can’t access the player mouse, so how does it know? The only way to get the client input to the server is with some kind of communication, like remote events. How do ClickDetectors get passed this? Do they even use any communication or is it fully on the server.
It’s the same thing with .MouseButton1Down on Gui Objects. How does the server know when the client clicks the gui, with no communication? Doesn’t this defeat the laws of FE, or is it some type of built in function? If anyone could answer this, it would be great. :hear_no_evil:

1 Like

It does communicate, but it works differently. So the client will detect whether you are hovering and register the click, and then tell the server that it was clicked. The communication happens in the C++ side of the software, as they are not Lua based. Then, the C++ tells the Lua that it was clicked.


Thanks for the response. This definitely cleared up some things but I still have some questions. How exactly are they communicating? I’ve never learned C++ so I’m not sure how this will work. Also, since it is utilizing the client, is it possible for exploiters to exploit this and manage to use this communication whenever they want?

On the exploiters, possibly. I gave you an example of how this thing works typically, and how it is done properly. It might be too quick or subtle for it to be an issue, or it might have some form of range detection built in server side.

I don’t know C++, but it is bare-bones. It might use a module for sending the network info (basically a remote event equivalent) or maybe they created the ‘remote event equivalents’ from scratch. Either way, it’s the same as any network communication works. For clarity, the Lua doesn’t actually do any communicated. If I use a RemoteEvent, it does this.
(client) > script > remote event > C++ > (server) > C++ > remote event > script.
Most things you interact with on Roblox are handled in C++.

Thanks for the clarification, I’ll leave this thread open for a little longer incase anyone else knows some more .