I made this script to stop exploiters but it doesn't work. Can anyone help me? There's no output. It's supposed to check every 20 seconds to prevent lag is someone is exploiting. Also its in a normal script in the workspace.
01 | while wait( 20 ) do |
02 | for i,v in pairs (game.Players:GetChildren()) do |
03 | wait( 0.6 ) |
04 | H = v.Character.Humanoid |
05 | if H.WalkSpeed > 16 then |
06 | print (v.Name.. "also known as" ..v.Name:Sub( 1 , 5 ).. "has been caught exploiting. His or Her Walkspeed was changed to" ..H.WalkSpeed.. ". They will be kicked shortly." ) |
07 | wait( 5 ) |
08 | v:Kick() |
09 | print (v.Name.. "was kicked. Play fair, don't exploit." ) |
10 | wait( 5 ) |
11 | else |
12 | wait( 0.6 ) --to prevent lag |
13 | end |
14 | end |
15 | end |
16 | end |
01 | local MaxSpeed = 16 -- Max speed possible in game |
02 |
03 | -- Note: I've added a rule-counter, which means you have to go too fast for 2 ticks to get punished. |
04 | -- That's necessary for teleporting by spawning, maybe your admins tp'ing, entering a vehicle, ... |
05 |
06 | local caught = { } |
07 | local function punish(plr) |
08 | if caught [ plr ] then |
09 | -- More than 2x too fast in a second? Seems like he needs to get punished |
10 | -- (As far as I know, it's impossible to teleport 2x in a second without exploiting) |
11 | -- (Assuming that people don't use admincommands teleport/ very fast) |
12 | -- (Also assuming that the game doesn't teleport someone 2x in a second) |
13 | if tick() - caught [ plr ] < 1 then |
14 | -- Should never fail, as we don't check RobloxLocked players |
15 | -- Even if it fails, punish() is called in a pcall() so it's safe anyway |