Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How come my anti speed exploit script isn't working, I need help?

Asked by 3 years ago

So this is my attempt on making a anti speed exploit (NOTE: THIS IS MY FIRST TIME DOING THIS). This is in a server script and in StarterPlayerScripts. It's not working when I go over 50 or directly on 50. Any help?

local Players = game:GetService("Players")

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        local humanoid = char:WaitForChild("Humanoid")
        while true do
            wait()
            if char.WalkSpeed >= 50 then
                player:Kick("Exploiting")
                wait(10)
            end
        end
    end)
end)
0
When exploiters speedhack, they change their WalkSpeed clientside. While the stored property value doesn't replicate to the server, their position does. There are a bunch of existing articles on exploit mitigation, I'd read into them if you want some more ideas. amanda 1059 — 3y
0
Adding on, you could check for player velocity on the server to see if they're speed exploiting locally. nekosiwifi 398 — 3y

2 answers

Log in to vote
1
Answered by
CjayPlyz 643 Moderation Voter
3 years ago
Edited 3 years ago

Exploiters change their walk speed client side, which means if you look at the exploiter's walk speed server side it would be unchanged. Another way to check for their walk speed server side is by checking their velocity.

local maxspeed = 22 --The maximum distance the player can travel within a check time. Try to keep this higher than 16.
local checktime = 1 --How many seconds we wait before we record their speed.
--If we make checktime too fast, like ".1", the script will be recording positions too fast and thus will fail to work correctly!

local root = script.Parent:WaitForChild("HumanoidRootPart") --Get HumanoidRootPart so we can keep track of the player's position.
local lastcf = root.CFrame --We will store the player's CFrame so that we can move the player there if they seem to be hacking.

while wait(checktime) do

   if math.floor((Vector3.new(lastcf.p.X, 0, lastcf.p.Z) - Vector3.new(root.Position.X, 0, 
root.Position.Z)).magnitude) > maxspeed then --We compare the length of the last known position, lastcf.p, with the current position, root.Position. If it's greater than maxspeed, they're hacking.

      --See how we ignored the Y axis in the calculation? Also notice how we rounded on the line above? This prevents an inaccurate reading.

      print("Hack detected for "..script.Parent.Name.."!")

      root.Parent:SetPrimaryPartCFrame(lastcf) --The player is hacking! Because this could be a false positive, we DO NOT KICK THE PLAYER. Instead, we peacefully move them back to their last known valid position!

   end

   lastcf = root.CFrame --We store the player's position so we can see if they're hacking later!

end

Script is from https://devforum.roblox.com/t/how-to-prevent-speed-hacking/210733

Ad
Log in to vote
-1
Answered by 3 years ago

It's not a good idea to kick someone as it could be false flagged via other scripts, instead make an accumulative point system that would help (optional, still what I prefer to do)

The reason yours doesn't work is because it's a server script, and changing speed is client sided manipulation. Consider changing it to a local script, which will be less secure, but if you hide it well enough and add enough counter measures to ensure it doesn't get deleted, it will withstand most exploit attacks. Also consider obfuscating so scripts like Infinite Yield Admin won't pick it up with their anti client kick feature

Good obfuscator: https://obfuscator.aztupscripts.xyz/

0
No. NEVER. EVER. EVER. EVER use a localscript for anti-exploits. Exploiters have the power to do ANYTHING client-sided, including modifying localscripts, deleting and etc. Obfuscating localscripts offer no protection, as they can easily be deleted. nekosiwifi 398 — 3y

Answer this question