Anti Fly (server side)

I’m trying to make an Anti-Fly script (server side) by checking the HumanoidRootPart's position on the Y axis, and if there in the air higher then they can jump for a certain amount of time, I respawn them, but I’m not sure how I would go about making this, I cant just check the Y value too see if its too high, because that can cause too many false positives…

Any help is appreciated! :+1:

1 Like

Try Ray-casting down and getting the height difference between their feet and the hit position

If I did that, then I could get a false positive if they were to jump from a high distance.

1 Like

Really a lot of fly hack scripts insert body gyros so I’d look for those as well as what dudesa said.


I said in the OP “Server Side”.

1 Like

There is only two things you can check server side that is velocity and position.

I am almost certain there is no other way…unless the HumanoidStateTypes are replicated which they probably aren’t and you could get around that by disablign them too.

You might just want to put an kick system and report system in place. much easier to do


The current fly hacks are with tweenservice so good luck. I noticed that the characters are in the air, but have walking animations always.

How is anyone supposed to prevent that?

I don’t even think you can, phantom forces also has tons of people using that right now. It would be pretty cool is roblox just gave us access to the tweens in tweenservice, to simply compare whats running in tweenservice to what we actually want.

1 Like

Also what i meant by the walking animation, is that normally when you’re off the ground. You have a jump or falling animation, not a walking animation

There is a way to detect it using a zone script, obviously, you know they can’t reach certain areas, if you were to mark all the areas they could touch (including a little bit off of cliffs in case they jump off) then a flying person would get flagged if they somehow exited the area.
If you choose this option I highly recommend you check out zoneplus V2

I’m trying to make an Anti Fly system (server side) using ray casting or Roblox physics.

The only way I could think of doing this without using zones is checking for nearby cliffs using a ray to the nearest cliff, however this seems like a worse solution than simply running zones

I’m not talking about cliff’s, I’m talking about the whole game in general.

I’m aware that’s what you mean, but regardless the only way you could avoid the aforementioned false positives is to check If they jumped off a cliff, which is why you would check if there is a nearby cliff.

This is very doable

Make a raycast down, and compare the position.
Like this;

	local RaycastDown = workspace:Raycast(self.Character.HumanoidRootPart.Position,,1,0) * -250,Params)
		if (RaycastDown) then
			if (self.Data.LastFlyPosition) then
				local DifferenceY = (self.Character.HumanoidRootPart.Position-self.Data.LastFlyPosition).Y
				if (DifferenceY > self.Humanoid.JumpHeight * 1.2) then
				elseif (math.floor(DifferenceY) == 0) then
					self.Data.LastFlyPosition = self.Character.HumanoidRootPart.Position
				elseif (DifferenceY < 0) then
					self.Data.LastFlyPosition = self.Character.HumanoidRootPart.Position
				self.Data.LastFlyPosition = self.Character.HumanoidRootPart.Position

Here is a piece of an anti-exploit I made, hope it helps

Could you explain each part of the script?

DIfferencY is used to compare the last height from the new height.
If the height is higher than the humanoid jumppower, then he just gets kicked.

Elseif difference (Floored) is equal to 0, it’s just small changes like climbing.
so it resets lastflyposition.

But, if differenceY is less than 0, it’s falling so it resets the position

With the current set of tools available to developers, its hard to do this.

Personally, I would keep track of the last highest position they had the last time they were on the ground (You can use FloorMaterial and/or raycasting for this, record it every heartbeat or something) and then compare it to where they are in the air at each interval.

From what I’ve seen and used, you can connect an anti fly check function to heartbeat to run every 0.2-0.5 seconds.

Some ways to do this include:

  • compare last primary part positions in the y axis
  • raycast a certain distance down to validate if they are on the floor or in the air.
  • (i’ve never done this, but just an idea) region3 to detect any parts around the character (filtering its descendants) - no parts detected would mean they are in the air

These methods may be performance intensive so having a good interval (not to small, not to high), between checks is important.

The problem though lies within false positives. You could try having a maximum amount of flags, make it high, and if they have been detected multiple times, you could then respawn them or teleport them back. This can stop many false positives such as falling. Important: make sure that after each flag or exploit detected, have a 7-10 second (or however high you want it) cooldown before the next check.