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.
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.
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.
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.
That’s actually an amazing idea.
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
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.
Localscript in StarterPlayerScripts
local MaximumClicksPerSecond = 15
local KickMessage = ""
local PrintClicksPerSecond = false
local Player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local Clicks = 0
local function onInputBegan(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
Clicks += 1
end
end
UserInputService.InputBegan:Connect(onInputBegan)
while wait(1) do
if PrintClicksPerSecond then print("CPS: "..Clicks) end
if Clicks >= MaximumClicksPerSecond then
Player:Kick(KickMessage)
end
Clicks = 0
end
That works but It’s only really useful depending on what u need it for, if it’s a grindy game someone autoclicking 14 cps for days straight would bypass that, if the game is about clicking as fast as possible then people who can legitimately click 15+ cps won’t have a good time
Branching off what axospheric said,
You could record the os.time() say 10 times, and then if the difference between each click each time then kick the player,
Click.rbxl (31.8 KB)
Added things I read from replies on the post, not sure if they are correctly done though
I know this script is not perfect but this is what I use when I decide to detect auto clickers.
local time1 = 0
local time2 = 0
local sus = 0
userinputservice.InputBegan:Connect(function(input, gameProcessedEvent)
local inputType = input.UserInputType
if inputType == Enum.UserInputType.MouseButton1 then
if gameProcessedEvent ~= true then
print(time1,time2,sus)
if time1 == time2 then
time2 = time1
time1 = 0
sus += 1
else
time2 = time1
time1 = 0
if sus > 0 then
sus -= 1
end
end
end
end
end)
while true do
wait(.1)
time1 += .1
if sus >= 30 then
game.Players.LocalPlayer:Kick("hi")
end
end