Today, i created a really really simple Anti Auto Clicker to prevent people from Item clipping out of towers.
The issue is,
Takes a while for the anti auto clicker to realize after someone starts auto clicking
Players can still clip out of towers
Doesn’t activate at all on low FPS
If you switch tools really fast, it activates pretty quickly
Can someone help me out?
Here’s my script.
local click = 0
script.Parent.ChildAdded:Connect(function(obj)
if obj:IsA("Tool") then
if click <= 0.005 then
game.ReplicatedStorage.BreakPlayerJoints:FireServer() --Kills the player
end
click = 0
end
end)
while wait(0.005) do
click += 0.01
end
(this is a LocalScript in StarterCharacterScripts)
You could use the tick() function to find the time between clicks:
--local script in starter player scripts
local Players = game:GetService("Players")
local player= Players.LocalPlayer
local mouse = player:GetMouse()
local lastClick = -tick() --Gets the time (just a quick explanation, it's a little more complicated than that)
local clicks = 0
local maxClicks = 50
mouse.Button1Down:Connect(function() -- This function is called whenever the player left clicks (or taps on their screen on a mobile device)
if tick() - lastClick < 0.05 then --if the time between the current click and the last click is less thna 0.05 then add another click
clicks = clicks + 1
else
clicks = 0 -- they aren't clicking fast, so reset their clicks
end
if clicks >= maxClicks then
-- best to kill directly from the client or else an exploiter can easily avoid the punishment by deleting the remote event
if player.Character then
player.Character.Head:Destroy() --when the head is destroyed the player dies, the head being destroyed will replicate to the server since the client has complete control of their character
end
end
lastClick = tick()
end)
I tested this with my auto clicker and it works great, you may want to change the maxClicks variable a bit, the lower of the number is the faster the auto clicker will be detected (don’t make it too low though).