How to detect flying correctly

I want to detect when the player is flying. But the script says they’re flying when even there foot is over the ledge. Because the raycast points down from the root but it doesn’t count the legs. And even if I raycasted from the legs there will be a point where they can stand on a ledge and it will activate the anticheat.

while task.wait(1) do
			local grounded = workspace:Raycast(root.Position, Vector3.new(0,-10,0), raycastParams)
			if not grounded and not facingPart then
				timeInAir+=1
				if timeInAir>12 then
					root.CFrame = lastCFgrounded
					amountOfSetBacks+=1
				end
			else
				timeInAir=0
				lastCFgrounded = root.CFrame
			end
			lastCF=root.CFrame
		end
3 Likes

Use FloorMaterial instead of raycasting. This allows you to check if the Humanoid is on the ground easily.

The anticheat can still activate if you ping spoof your window (on Windows, hold-clicking on the white bar).

Floor material can be changed by client.

Well then, we’d check if the legs were on the ground. If one’s on the ledge, check the other. If that’s on the ledge too, then we know the person is floating.

Read their positions from frame to frame, and if they move too fast, you can detect that (allow for some excessive numbers still, due to latency issues). Most people who cheat will cheat fly fast, not slow, and you’ll also catch walkspeed cheaters.

Next, you can try GetTouchingParts on a capsule part that is welded to their character. If it’s touching nothing, then they’re off the ground, and you can give them a certain number of seconds they are allowed to have a positive velocity (from jumping), then detect them as a cheater if they exceed that number.

1 Like

This can still be falsely activated.

What do you mean? Sure if the game is teleporting players or there are catapults and stuff, you need to code examples for that, but overall, it shouldn’t have false-positives if you account your times for latency