Anti-Exploit Help

Recently, I made this code to try and stop speed hacks:

while true do
	wait()
	if LocalPlayer.Character.Humanoid.WalkSpeed > 24 then
		RemoteEvent:FireServer("speed")
		LocalPlayer:Kick("Please turn off your exploits before joining back!")
		wait(10)
	end
end

However, I was told that it wouldn’t work because the WalkSpeed property of the player is not replicated to the server if it uses local scripts to change it. So, I was told to ‘make position checks’ and to ‘work with the velocity of a character’. Does anyone have any idea how to make this work?

1 Like

The issue with having your checks be local isn’t that they don’t work, they do and will probably catch most cases, but rather that they are easily circumvented by someone who knows a thing or two about this.

The argument is that because this code is ran locally, an exploiter could just choose to delete or disable the LocalScript thus stopping the check from happening. The solution is to have the check be done on the server instead, but the issue there is that when an exploiter changes their walkspeed property, the server doesn’t see this change while everyone still sees them running across the map much faster than usual.

So what you instead have to do is a bit tricky: you have to have a regular check (maybe once every second or two?) to see if they didn’t travel too far from where they were during the last check. And because gravity screws with the Y axis here, often people will just check on the two X and Z dimensions, making the Y value of the recorded vector equal to zero. It’s messy and often will affect people who are lag spiking as well (they seem to teleport around sometimes) so you can’t kick them from the game but rather do something harmless like teleporting them to the last accepted position, for example.

Would this work if I have cars in my game?

What you would have to do there is to change the allowed speed from the Humanoid.WalkSpeed to how fast the car can possibly go when they step in the car.

1 Like