Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I make a simple exploit prevention system?

So this is what I have so far:

while true do
      wait(60)
      local plrs = game.Players:GetChildren()
      local chars = workspace:FindFirstChild(plrs.Name)
      if chars.Humanoid.Walkspeed >= 17 then
            local plr = game.Players.LocalPlayer
            plr:Kick("You were exploiting")
      end
end

I was trying to make a thing that checks the players' walkspeed and if it is over 16 it kicks them. But this doesn't seem to work. Could someone please help me here? Thanks in advance!

6 comments

0

I believe you cannot run a Kick() from a localplayer, or maybe it's just the wait(60) in the line.

0

I think Heartbeat event will work better(https://developer.roblox.com/en-us/api-reference/event/RunService/Heartbeat). It will fire everytime a new frame create. And we can use :Kick() from LocalScript.

0

No you can't

0

Wait, what? The document said that you CAN kick a player by LocalScript https://developer.roblox.com/en-us/api-reference/function/Player/Kick

0

You can kick a player in a localscript, you just can only kick yoursell.

0

You can check for abnormalities in the character or player's behavior, and using a whitelist you can bypass the abnormalities. If it's not supposed to happen, add their name to a ban list using data store, and kick them.

2 answers

For walking speed, you could calculate how many studs the player moved since the last frame and check how much time there has been between the last frame and the current and check if the player moved too much on the X and Y positions of the HumanoidRootPart. Although, for the Y positions, it would be much more complicated because the player can jump and fall. Also, you would have to account for any sort of moving platform (ie. car, train, etc) that moves in your game. If you have basic knowledge of physics, it should be easy. You should get familiar with roblox’s physics system if you want to make an anti-exploit script. That script you made will only prevent the player from changing the walk speed but there are alternatives like changing the position of the humanoid root part directly. If i’m not mistaken, anything that happens to the player’s character on the client side is replicated to the server. I don’t know if that’s entirely true but I’m pretty sure it is since animations are replicated automatically. If I am wrong, please correct me.

4 comments

0

? I am new to scripting.

0

If you’re new to scripting, I don’t recommend trying to make an exploit prevention system. It’s not as simple as checking if a few variables are higher than they should be. It’s about replicating the physics of the game on the server-side and checking if the player’s character’s position or whatever you’re trying to prevent closely corresponds to the estimated calculations made on the server.

0

But you have the walkingspeed already in the players traits.... Unless exploiters change the walkingspeed without changing the value of the walkspeed in the player 0.o

0

you can change the walking speed without changing the walking speed... you simply make your own walking script.

You could do a .Changed listener on the players walkspeed. If it changes then fire a even to the server to kick the player. I think..

You need a way to track the players walkspeed constantly. A while loop is not the way.

This discussion is preserved as it was. New answers, comments, and votes are closed.