How should I approach anti-fly?

Hey!
So I’m working on a tsunami-survival type game, and I’ve come across the thought of It’s really easy to fly hack over the tsunamis and win.

Right now I’ve made very basic anti-cheat on the client that detects when descendants are added to the players character which will stop most un-experienced hackers.

How should I approach to stop this?
I’m thinking of casting rays below the player, but this can be very un accurate (For example if a player is standing right on the edge to where only half of them are on, the ray would miss). Also I’m pretty sure firing raycast multiple times for every player isn’t very lag-friendly.

Are there any better solutions?

I strongly reccomend looking through #resources or #help-and-feedback to find a solution to this, as this topic has been discussed before.

Here’s a post to start off, this one has a good discussion on it.
How to make a basic Anti-Fly script

Some posts are more reliable than others though, so do try searching the forums.

I’ve looked through the post you linked and this still has the issue im trying to solve

The player is dangling off the edge, and the cast goes down and misses
Also, you could fire 3 rays, one for the outside of each leg, but lets say there are 15 players: 15*3 = 45 rays every heartbeat. This would be terrible for performance and my game is already pretty performance heavy as it is. I’m looking for a better solution (hopefully) not including heavy raycasting, unless that’s not possible

One solution you can try is checking if the humanoid is standing on a platform using Humanoid:GetState(), however, yes, there’s always the potential that this can be bypassed.

Again, it’s always good to look around the forums. I personally don’t know enough about anti-fly to give you the solution here, but I can almost guarantee that the answer is lying within the forums.

Thanks for helping, but I’m going to leave my post without marking your answer as solution to see if anyone has a better solution, because this has not fully answered my question

1 Like

The solution is to use the ray as a broad check, and then to use more expensive checks if the ray doesn’t hit anything.

My solution is to use Region3 to check if there are any possible parts that the player might be standing on. This solution isn’t perfect but it’s a good start.

I have an implementation of it here

I’ve looked through your script and I have a good understanding of how I should prevent flying. I’m working on adding on some more features. Thanks!

Sorry for the late response, but you should update your flying module with support for climbing, I keep getting refreshed for climbing a ladder that takes longer than 6 seconds

Alternitavely, I prefer using magnitude checks, where you check the player’s HumanoidRootPart magnitude every second and calculate to see if he has traveled farther than he could.

That’s for checking if they are going too fast, not for checking if they are flying.

If you implement the correct checks, then you can optimize it to be an anti-fly. So that if they fly and move even just 1 stud, then they’ll get kicked.

That still doesn’t make checking if the player’s speed is too high a valid way of checking for flying.

This response is implying that magnitude checks can still be changed to check for flying. Except it can’t.
You need to actually add a fly check to well check if they are flying.

I don’t want to be rude but the idea of this post is sort of like saying
“If you implement the correct colour and taste, then you can optimize this apple into an orange. So if you bite into it, it’ll be an orange”