I’m coding an advanced anti-speed-hack myself. One of the key factors one should take into account is that some players (especially the ones playing with their friends overseas with really high ping) will experience light to moderate ping jitter. Ping jitter is basically the ping value changing over time and it can change spontaneously in magnitudes of up to 250 milliseconds (A Roblox character could walk 4 studs in that period of time). During the moment the ping is increasing for a player, the server will not receive position updates for a bit and the player movement will literally start looking jittery for other players.
Thankfully Roblox does some physics prediction and smoothing server-side, so it will make speed exploit detecting scripts get angry less, but only to certain amounts of jitter.
JItter tolerance is easy to apply once you know what would be the best jitter tolerance value that would suit the majority of roblox players. Recently I’ve noticed one player who experienced instant ping changes up to 200 ms and that player might start having issues with your code. I’m still not sure what kind of ping jitter does the great majority of the Roblox playerbase experience and thus it requires more research.
Once you know what would be the ideal ping jitter tolerance, you just multiply your max tolerable velocity by (1 + ping jitter tolerance in seconds).
For example, if we decide to tolerate 250 milliseconds of ping jitter with 16 walkspeed:
16 x (1 + 0.4) = 22.4
(Players with less than 250 millisecond jitter should not exceed the speed of 22.4 studs per second.)
However, in practice, if you tried to read player position delta server-side you’ll find out that server will observe jittery position changes in player HumanoidRootPart even when their internet connection is not jittery at all. In that case you’d have to add even more tolerance overhead to protect the more “jittery” players from getting annoyed by your anti speed hack. But that’s where it would start falling apart - if our new tolerance values allow non-jittery players to achieve speeds of well beyond 20 walkspeed, then we have failed to make a meaningful anti-exploit.
Fortunately - If we track the history of player positions for the last “max_jitter_tolerance x 2” (eg. 500 ms) seconds and find the difference between position1 which existed, for example, 500 milliseconds ago and position2 which is the position the server is experiencing currently, we will see the TOTAL of distance the player has moved over the past 500 milliseconds. If the maximum jitter a player was experiencing was below 250 milliseconds, then the total distance moved (That was experienced server-side) in those 500 milliseconds will be much more likely to be closer to “WalkSpeed x 0.5 seconds”, and we’ll need way less tolerance overhead to make the anti-exploit less sensitive to other unexpected stuff.
Hopefully someone will make sense of what I’ve written here lol.
Also it should be obvious that this would only work on players that are not moving inside a vehicle. Vertical exploit detection is possible, however it gets much more complicated lol.