Would this be a good way to detect speed exploiting

Hey guys I made this anti exploit script do you think it would be a good way to detect speed hacking

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        while wait(10) do
            local oldlocation = char.HumanoidRootPart.Position.Z
            wait(10)
            local newlocation = oldlocation - char.HumanoidRootPart.Position.Z
            
            print(newlocation)
            if newlocation > 500 then
                plr:Kick("Speed hacking")
            end
            
        end        
    end)
end)
2 Likes

What if such user uses a speed command if the game has admin? I’m just a builder so i really don’t know.

1 Like

nope the game does not have admin

But let’s say I have this code in my game (which i won’t cause idk how to script and that is theft)
And i also have admin. and i give a user admin and he uses the speed command. Would the user be kicked because of that?

If the player gets teleported, the script will think they’re speed hacking.

2 Likes

it would kick if they walked 500 studs in less than 10 seconds

@Deezylolz You would want to check the magnitude between the two points.

@VaderGoalie You could just check if they were an admin before kicking them, or check their rank.

Ah i understand now. Thanks for the relpy.

I believe he’s making a temporary solution.

And to add on to that you could make a event when the player is teleported or given speed by a ADMIN that tells the code not to kick that player.

What if the player gets flinged somehow?

I believe this solution is better:

  plr.CharacterAdded:Connect(function(char)
      char.Humanoid.Running:Connect(function(speed)
      If speed > 40 then plr:kick()
             
end)
end)

Reason we use > 40 its because humanoid.running parameter return the absolute player speed so if the player glitches then the speed would go up to 16

but the player speed doesn’t replicate to the server so we need to check for distance

You can use this module:

Actually humanoid.running don’t give the player walk speed it give the player absolute speed which mean if the player is going fast and his walkspeed in the server is 16 then in the humanoid.running it will be more than that

The player speed number doesn’t replicate to the server

sorry but I didn’t understood what you said above

Wdym by player speed number? Do you mean the humanoid walkspeed don’t replicate from client to server ?

1 Like

Yes…

I need to write here

Yea but humanoid.running don’t return the humanoid walkspeed it return the player absolute speed which mean if the player is going fast it will have a velocity which is replicated and this function get that and turn it to speed idk how its turning it but there is a formula to that

1 Like

Why not to check distance from the last position of HumanoidRootPart?