How do you distinguish flying from falling when making an anticheat?

So I’ve started making an anti-cheat and doing some simple velocity checks stop speed hacking and JumpPower, and this does technically stop flyhacking but it also fires when someone is falling from a high place. How do I distinguish flying from legitimate falling?

My only idea so far is to shoot some raycasts maybe like 5 studs down from the player’s rootpart, and then for each check interval, if the raycast doesn’t hit a part, then peg and record it in a table and call it a “fly count.” Then if the raycast doesn’t hit a part for an unusually long amount of time where it would mean that the player isn’t falling but has to be hovering for some sort, the flycount would be high and then I could kick the player. For a usual player falling, the raycast would hit something eventually in a short amount of time and then I could reset the flycount. Laggy players shouldn’t be able to trigger this either.

I don’t know how effective this idea is though and I want to hear some of your methods.

1 Like

I think your exploiters would catch on and realise they just need to get close to the ground every so often.

I think perhaps using the direction of their velocity is more important, as falling will be mostly downwards, whereas flying will mostly be in the X-Z plane. You could dot/scalar product the unit vector of their movement against a global down unit vector (0, -1, 0) and the closer to 1 the result is, the more downward their motion is. The closer to zero it is, the more horizontal it is.

You could always combine the two.

2 Likes

Would that still work if the Player were to be flung into the sky on accident?

If that were a thing that regularly happened in their game then you’d probably want to account for that too.

I’d always advise strongly against permanent bans or even temp bans as a result of velocity and position checks due to physics bugs that occasionally arise. So long as people only Kick in these types of checks, generally it’s not too big of an issue.

2 Likes

This sounds like a good idea. This paired with my method would be a really strong way of solving fly hacking.

Thank you!