Anti exploit "bug"

Hey there! I am currently working on a game, and I am creating an anti exploit for it. This anti exploit stops players from changing their speed on the client. Here is my code:

game.Players.PlayerAdded:Connect(function(player) 
	player.CharacterAdded:Connect(function(char) 
		local hum = char:WaitForChild("Humanoid") 
		hum.Running:Connect(function(speed) 
			if speed > hum.WalkSpeed + 1 then
				player:Kick("Lol nice exploits")
			end
		end)
	end) 
end)

This works, however, when they go on a conveyor belt, it detects it as an exploit, as they are walking faster than their walk-speed.

Any help would be greatly appreciated!

Edit: I have tried creating a value in the player and if they touch a conveyor it sets to true, but it is very buggy, and doesn’t work well AT ALL

Edit 2: This script is on the server, in case anyone didn’t know

1 Like

Okay so there’s a lotta things I gotta say, bare with me:

  1. NEVER put anti-exploit scripts on the client. The exploiter can EASILY delete the script, and render it completely useless
  2. You may or may not be using a free model conveyor that modifies the humanoid’s walkspeed, thus the client anti exploit script picks it up
  3. Don’t kick on the client. It doesn’t really work that well. Try kicking on the server using RemoteEvents.
  4. I don’t suggest making anti-exploit scripts at all, because either way the exploiter would eventually bypass it anyway. Start investing more time into server-side security
2 Likes

Their exploits are client sided, so you can’t check their walkspeed on the server (i think).

2 Likes

Yes, this is true but look at what I said:

The exploiter’s territory is the client, and the only bridge to the game is remote events and remote functions. This is why you need to have server-sided “if” checks, isntead of the client

1 Like

This is on the server though lol

1 Like

Oh! My bad :joy: I thought you were doing that on the client

But anyways, on other terms that script won’t really do anything, since if an exploiter modifies their walkspeed, it’ll only appear the client, and it’ll appear normal on the server

And also, keep in mind what I said here:

1 Like

No, as the humanoid.running() has 1 default argument, speed. This means you can check how fast the player is walking, and compare it to the player’s walkspeed on the SERVER. So if a player changes their speed on the client, it will kick them as their speed argument is more than their walkspeed on the server

1 Like

Hm, I haven’t tested that out but that sounds reasonable.

2 Likes

if the player is above what you would consider exploiting, cast rays downwords and subtract the magnitude of the velocity from the hit object from the speed. but also i wouldnt kick them i find a “rubber band” effect is way better

2 Likes

How would I go about doing this? I am not very familiar with rays

Don’t detect walkspeed as the server can’t detect walkspeed changes through client.

@RatiusRat This explains what the script does

You can’t really do anything about exploiters changing their walkspeed.

Yes, you can. If you want, you can copy and paste the script into studio (On the server) and give it a try yourself. When you change the player speed on the client, it kicks you, but when you change it on the server, it doesn’t.

But exploiters can easily change that localscript?

Nevermind this actually works since the walkspeed is set on the server.

1 Like

RayOrigin = Root.Position
RayDirection = Vector3.new(0, -100,0)

and then just use the code on the wiki for raycasts, make the blacklist Character:GetDescendants()

1 Like

Maybe setting a limit for the player’s walk speed? So if the walk speed exceeds than, you can set it back.
There might be a problem with client-server.

1 Like

the Running function just returns the characters overall speed, not there walkspeed, you are faster on a conveyor belt thus it returns that instead of its walkspeed

trying printing out “speed”, you will notice how it would be printing out numbers that aren’t your walkspeed often

1 Like

I re-maken your code, cause there could be 2 whitelisted WalkSpeed. I don’t know why I re-maken it, but, honestly:

local whitelistedSpeed1 = 16
local whitelistedSpeed2 = convoyorspeedhere

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local hum = character:WaitForChild("Humanoid")
if hum.WalkSpeed ~= whitelistedSpeed1 or whitelistedSpeed2 then
player:Kick("hi there ur hacks are cool now get out of here :)")
  end
 end)
end)

Also, putting it on the client is a risk.