Hey Developers,
So I am making an anti-exploit script for my game. It is not working.
Here is my script:
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function()
Player.Character.Humanoid:GetPropertyChangedSignal('WalkSpeed'):Connect(function()
if Player.Character.Humanoid.WalkSpeed > 30 then
Player:Kick('Exploiting')
end
end)
Player.Character.Humanoid:GetPropertyChangedSignal('JumpPower'):Connect(function()
if Player.Character.Humanoid.JumpPower > 0 then
Player:Kick('Exploiting')
end
end)
end)
end)
I am getting no errors in the output. Thanks for any help.
Hey there!
You are checking the values from server-sided script. Exploiters executes their script locally, meaning you will have to check for the changes locally also. Put this script into StarterPlayer.StarterCharacterScripts (as a LocalScript) and it should work.
Code:
local humanoid = script.Parent:WaitForChild("Humanoid")
local player = game.Players.LocalPlayer
humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
if humanoid.WalkSpeed > 30 then
player:Kick("Exploiting")
end
end)
humanoid:GetPropertyChangedSignal("JumpPower"):Connect(function()
if humanoid.JumpPower > 0 then
player:Kick("Exploiting")
end
end)
This is not the best way to make an anti-exploit script since it is a local script. Exploiters can delete local script. So the best maybe not the best way is to check Magnitude on the server.
That is a good start, but they can just decompile the script. Plus, there are super common anti exploit tricks that tons of developers use that can be universally bypassed (such as fly and speed checks, and kicking on the client can all be bypassed quite easily) and so in the end it might not matter too much what you name the script or how easy you make it accessible.
When checking for changes in the speed and jumppower, it is better to look towards changes in the velocity and position on the server rather than trying to get info off of a malicious client. You could also check these values with the client’s inputs to see if they make sense.
A rapid change in positon or velocity can be caused by a physics glitch, so its also better just to correct the position than ban/kick the player. Only ban the player when they’re using remote functions/events that they shouldn’t have access to, or they’re being fired in an abnormal way.
I would not recommend using simple methods to prevent exploits since there are a lot and I mean A LOT of methods to fake values, most anti-exploits are based on NetworkSpeed and more advanced techniques on identifying exploiting hacks.
Most of the kids using exploits have no idea what they’re doing, they just inject some random dll they got off the internet into the client. Client-sided exploit prevention can help stop people like those.
Never use client side anti-exploit. Instead of checking walk speed and jump power try calculating their speed server side in studs etc. There are many module scripts that use this method.