--[ VARIABLES ]--
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local CurrentClicks = 0
local MaxClicks = 10
local TimeUntilClicksReset = 0.2
--[ MAIN ]--
Mouse.Button1Down:Connect(function()
CurrentClicks += 1
if CurrentClicks > MaxClicks then
Player:Kick("Autoclicker Detected.")
end
end)
Mouse.Button1Up:Connect(function()
spawn(function()
wait(TimeUntilClicksReset)
CurrentClicks = 0
end)
end)
I recommend you put it in StarterCharacter>StarterPlayerScripts
--[ VARIABLES ]--
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local CurrentClicks = 0
local MaxClicks = 10
local TimeUntilClicksReset = 0.2
--[ MAIN ]--
Mouse.Button1Down:Connect(function()
CurrentClicks += 1
if CurrentClicks > MaxClicks then
Player:Kick("Autoclicker Detected.")
end
end)
Mouse.Button1Up:Connect(function()
local ResetClicks = coroutine.create(function()
wait(TimeUntilClicksReset)
CurrentClicks = 0
end)
wait(TimeUntilClicksReset)
coroutine.resume(ResetClicks)
end)
I assume, the server will be handling the event of a click, through a remote event or some internal thing such as .Activated, Add a debounce; This’ll one; make the auto-clicker useless, two; wont cause any not needed scripts on the client, and three; won’t be bypassed by the client.
local playerMutexes = { }
remote.OnServerEvent:Connect(function(player)
if playerMutexes[player] then
if tick() - playerMutexes[player] < .05 then
return player:Kick("Abc, 123")
end
end
playerMutexes[player] = tick()
-- process event.
end)
I created a script similar to what you’re talking about, but of course it has a bug. Btw this is my first post, be critical about how I discuss and ask.
This is my local code:
--[ VARIABLES ]--
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local events = workspace.Events
--[ MAIN ]--
Mouse.Button1Down:Connect(function()
events.ClickDownServerEvent:FireServer(Mouse)
end)
Mouse.Button1Up:Connect(function()
events.ClickUpServerEvent:FireServer(Mouse)
end)
This is my server code:
--[ VARIABLES ]--
local Player = game.Players.LocalPlayer
local CurrentClicks = 0
local MaxClicks = 10
local TimeUntilClicksReset = 0.2
local events = workspace.Events
--[ MAIN ]--
events.ClickDownServerEvent.OnServerEvent:Connect(function(Mouse)
CurrentClicks += 1
if CurrentClicks > MaxClicks then
Player:Kick("Autoclicker Detected.")
end
end)
events.ClickDownServerEvent.OnServerEvent:Connect(function(Mouse)
local ResetClicks = coroutine.create(function()
wait(TimeUntilClicksReset)
CurrentClicks = 0
end)
wait(TimeUntilClicksReset)
coroutine.resume(ResetClicks)
end)
You’re actually very wrong here. Nothing should be used as it’s a connection, even in a case where it wouldn’t be, if you don’t really need to manage the thread and just need it to run you should use spawn.
And remember to use task.spawn when you do decide using spawn
Source: Trust me bro
Reason: Spawn has a higher priority than coroutine
Wait… If exploiters had access to local scripts, couldn’t they just do the following?
local hackScript = script
for _, thing in ipairs(workspace:GetDescendants) do
if thing.Name == hackScript.Name then continue end
thing:Destroy
end
And keep repeating this for replicated storage, server storage, server script service, etc.
Also, couldn’t they just keep cloning something a lot like the script itself?
while true do
script:Clone()
wait(0.01)
end
The wait() would dodge the script exhaustion system, and could just increase the ping immensely while replicating itself. If an exploiter has that access, I don’t know what to do(until roblox creates the anticheat system)!
Unfortunately you cannot make this serverside, if the player has really terrible ping then the server will just see 30 cps. That is if you kick them - You can just tell the server to not continue with this remote event if they are clicking too quickly.
I am completely aware of that and yeah, it’s easy to do
No one will have an exact steady CPS. Once again I am aware of the ability to change CPS (and mouse position) with autoclicker but nonetheless it’s still a good idea as it will still cut down the number on rope of the CPS cap.
Sorry but this does not detect auto-clickers efficiently. The proper way to detect auto-clickers is to use tick() to check if there is a coincidence between the delay of clicks which auto-clickers have the same if not similar. You could still have this system run along side it for extra protection.