There is no really a reason to make client side autoclick prevention as it does not really gives an advantage to the exploiter, also exploiters will be able to bypass any check you implement on client-side, it’s just a matter of time.
If you want to implement something server-side secure, then you should learn how the client-server communication works in Roblox, you can find it here and in other related topics.
I understand, I’m trying to make this so people who don’t exploit, cannot manage to use autoclicking. Because if there were to be an exploiter, there aren’t really anything you can do when they bypass. Owning an autoclicker application would be more common than exploits.
I think you’re close, just a bit overly complicated. We just need to loop every second, check if our clicks over time (deltatime should be close to 1) are greater than 50, and then kick if that is the case. (But yeah, trusting the client is a bigger issue altogether)
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local cpsLabel_L = script.Parent:WaitForChild("LeftCPS")
local cpsLabel_R = script.Parent:WaitForChild("RightCPS")
local clicksL = 0
local clicksR = 0
mouse.Button1Down:Connect(function()
clicksL = clicksL + 1
end)
mouse.Button2Down:Connect(function()
clicksR = clicksR + 1
end)
while true do
local deltatime = task.wait(1)
if clicksL/deltatime > 50 then
plr:Kick("Autoclicking Prevention")
end
cpsLabel_L.Text = "LeftMB_CPS: " .. clicksL
cpsLabel_R.Text = "RightMB_CPS: " .. clicksR
clicksL = 0
clicksR = 0
end
You shouldn’t worry about what inputs the user is sending. Worrying about what effect they’re having on the game. Does an auto clicker let them instantly kill other players? Detect that directly instead of tunnel visioning on the specific interface they happen to use.
This game I am attempting to create is nearly all about cps, although I do not wish players to use unfair advantages such as autoclicking, and exploiting.
wait and task.wait both return a number which is the time it takes for the wait to actually happen. If for some reason task.wait(1) takes 1.1 seconds to run, we shouldn’t punish players for getting 50 clicks in, since that’s no longer actually 50 cps, it’s 50 clicks / 1.1 seconds or 45.5 cps. That’s all I’m doing by getting a deltatime. Hopefully that makes sense.