Hello,
I’m currently working on a system, that can some-what reliably catch speed and teleportation exploits, and teleport players back, but I’m struggling a little on getting accurate results, as well as actually making flight catching…
I’m using a Heartbeat event and it’s provided delta time to calculate velocities, and it works some-what well for XZ velocities, usually ± 5 stud deviation from humanoids walk speed, and if any anomaly is detected - I send them back to last safe position.
Idea with acceleration/ jerk/ difference in velocity was to check, weather player is affected by gravity, because if he wasn’t, it would be pretty clear that player was forcing himself to stay up, aka, flying.
Problem is, i’m getting some really inconsistent data, and I’m not sure how to interpret it/ what am I doing wrong…
Code:
RunServ.Heartbeat:Connect(function(timeElapsed) for i, player in ipairs(game.Players:GetPlayers()) do local char = player.Character if char and timeElapsed then local humanoidRootPart = char:FindFirstChild("HumanoidRootPart") local humanoid = char:FindFirstChild("Humanoid") if humanoidRootPart and humanoid then if playerData[player] and humanoid.Health > 0 then local lastTimeElapsed = playerData[player].lastTimeElapsed local lastPos = playerData[player].lastPosition local lastLastPos = playerData[player].lastLastPosition local lastStandPos = playerData[player].lastStandingPosition local currentPos = humanoidRootPart.Position local Standing = isStanding(char) local Velocity = Vector3.new() if lastPos then Velocity = (currentPos - lastPos)/timeElapsed end local VelocityXZ = Round(Vector3.new(Velocity.X, 0, Velocity.Z).Magnitude, 3) playerData[player].lastPosition = currentPos playerData[player].lastTimeElapsed = timeElapsed playerData[player].lastLastPosition = lastPos if Standing == true then playerData[player].lastStandingPosition = currentPos end print(VelocityXZ, Velocity.Y, workspace.Gravity * timeElapsed) if VelocityXZ > Default_Walk_Speed + Max_Allowed_Speed_Variation then teleportToLastPos(player, lastPos, lastStandPos) end end end end end end)
Output:
I thought that Velocity.Y should change based on gravitational acceleration, which, at that scale is seen on the right side, but it clearly fluctuates?!
How can I get more accurate data? How does Roblox itself do it?
BTW: I did print(Velocity.Y, humanoidRootPart.Velocity.Magnitude) and it’s clearly smoother: