How to make an Anti-Auto-Clicker?

I want to achieve an Anti-Auto-Clicker script for a game.

I need it because in the game there are some mechanics that the player can avoid doing manually just by using autoclickers: EG hitting a dummy/being in the game a needed amount of time to gain something.

I really have no idea how to do it.
I would be thankful if you would give me your Anti-Auto-Clicker script prototype.

One of the problems I encountered was the timer script ( I don’t even know how to make him) and how to create a new variable each time the click is triggered so if all the variables match it will kick the player.

7 Likes

You could count how many times a Player has clicked the screen and if the number of clicks (x) goes over this amount (y) under this much seconds (z), its probably an auto-clicker. I would personally do something like that.

3 Likes

There’s multiple things you could do.
If the issue you have is autoclickers clicking very fast, you could just add a simple debounce to set a min. time between clicks.
If the issue is that you don’t want people auto clicking at all, then it becomes a bit complex.
You can, like TerrorPieYT says, check the time between clicks to check wether or not someone’s using an auto clicker, and kick them if they are.
That gives the problem that people could perhaps simply slow down their auto clicker until they don’t get kicked.
Perhaps the best way to do it would be to calculate the time between clicks, decide a tolerance value, and if the time between clicks is too consistent (running it by the tolerance value) then they’re most likely using an autoclicker and should be kicked.
I.E: Give the checking script a tolerance of 0.05 seconds. If someone’s consistently clicking at the same speed, and not waivering more than 0.05 seconds, you can assume they’re autoclicking.
Hope that helps.

2 Likes

A debounce or leaky bucket algorithmic approach can help you here.

Leaky bucket especially stops spam situations like these based on how fast the requests come in.

1 Like

You can’t prevent it, there is no way to detect it. Some people can click faster than auto clicking. Personally, I have 14 CPS, enough to get me banned from a Minecraft server. You can use a debounce, but, it depends on if you want your players to wait some time before clicking again.

3 Likes

You can also just allow every X seconds to be 1 click. Like a very short cooldown.
I suggest experimenting with it.

First Method
Standard simple debounce script.

local debounce, timeout = true, 0.125
function playerClicked()
	if debounce then
		debounce = false
		-- Do whatever you want here
		wait(timeout)
		debounce = true
	end
end

Cons: Can’t detect if player is using auto-clicker, forces player to wait until script allows to click again

Second Method
Good if you want to detect usage of auto-clicker or unusual amount of clicks in a short amount of time.

local clicks, limit, timer = 0, 100, 1
function playerClicked()
	if clicks < limit then
		clicks = clicks + 1
		-- Do whatever you want here
	end
end
while wait(timer) do
	clicks = 0
end

Pros: Can detect if player is cheating, doesn’t force player to wait until script allows to click again

Hopefully this explained how to use two most common methods of stopping usage of auto-clickers.

However, keep in mind, that this only applies to usage of fast auto-clickers, but nothing can detect an auto clicker that clicks slowly with breaks.

6 Likes

I’ve been thinking about this for a while. My idea (not flawless) is to have a GUI pop up every 5 minutes (if the player is not moving or something) that says “You have not been (blank) for 5 minutes. Click this button so we can make sure you are not AFK.” (put a button under the message) Also, if they don’t press the button in 1 minute or so, they are kicked.
Also, you should make the GUI pop up in random locations. If you make it random though, make sure it is completely visible.

2 Likes

Sometimes it just won’t work. Me personally can click up to 20 clicks per second and that would 100% kick me even if I didn’t use any auto-clicker.

Method 1 is more effective in my opinion, as it forces them to wait, they can’t achieve their goal of autoclicking to earn points / cash / etc.

I have made recently a system like this for a simulator and I used debounce and wait().
And for the wait I used in this type of for:

Cooldown  = 0.2
wait(cooldown + 0.5)

Yes it forces them but could they both somehow be combined so the player is forced by the debounce to not earn points fast but if he clicks too fast he still gets kicked?

Make a table that is populated each time a player clicks with the time since their last click. Every n clicks, calculate the standard deviation of the dataset, if it’s lower than a certain threshold, then assume that the player is using an auto-clicker. Empty the table and repeat.

1 Like

Make sure they move their mouse, at least every minute. As a normal person, I wouldn’t angle my hand above my mouse in some weird position and click like that, even so, I might still move the mouse. The autoclicker, however, would not.

Add on to this with an algorithm that keeps an array of delta time between current and last click. Then, check if the distance from the avg. time between clicks is under a certain number. If it is, ignore all their clicks until they make their mouse click at different rates AND move their mouse.

Also add a debounce. (as previously stated); Get a test group of pro clickers and see how many times a sec they click. Then, the top person you saw, add a few extra clicks (just in case), then divide 1 by that number. That is your debounce delta. Should be around in the 10-15 range. I can only click 7CPS, and that is me trying hella hard.

Keep in mind this only will work for non-exploiting auto clickers. This should be done locally, but you should be assuming the person isn’t exploiting/hacking. If they are, they can delete your scripts. This should work well for the majority of auto-clicking cheaters.

Flawless way to do it. :wink:

1 Like

That’s actually an amazing idea.

3 Likes

Where does this go? Starter player? Server script storage?

Disconnect the connection with mouse after every time the player clicks to fire their weapon. This code would only be useful for a pistol/semi-auto weapon. Otherwise the code would be your standard while MouseDown function.

Which Code? There are Many Codes In This Thread

Most autoclickers are very static, by this I mean they are very timed, when people click it’s not very timed at all, if you notice a repetitve pattern in terms of time since last click then you can detect whether they are autoclicking or not

1 Like

Agreed, this is probably the best approach for this issue. For those of you who are confused, you can use os.time’s to find the time in between the clicks.