Server Side Anti-Fly

The title says it all…

How would I go about making a Server Side Anti-Fly?

Your help is much appreciated! :+1:

I think you would do something like detect how high they are from the ground, velocity, and direction they are moving. From there you can determine if they are flying

I already had that in mind but how would I do that? could you give some example code, I’m not asking for entire scripts, I’m just asking for a basis of how I could go about that.

ya gimme sec to put it together

the script would be smthg like

function tooHigh(hrp)
	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = {hrp.Parent}
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	local raycastResult = workspace:Raycast(hrp.Position, hrp.CFrame.UpVector * -1, raycastParams)
	if (raycastResult.Position - hrp.Position).Magnitude >= 50 then
		return true
	end
	return false
end

function tooFast(hrp)
	if hrp.Velocity.Y > hrp.Parent.Humanoid.JumpPower or hrp.Velocity.X > hrp.Parent.Humanoid.WalkSpeed or hrp.Velocity.Z > hrp.Parent.Humanoid.WalkSpeed then
		return true
	end
	return false
end

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local hrp = char.PrimaryPart
		while wait() do
			if char.Parent.Humanoid:GetState() ~= Enum.HumanoidStateType.FallingDown and char.Parent.Humanoid:GetState() ~= Enum.HumanoidStateType.Ragdoll then
				if tooHigh(hrp) and tooFast(hrp) then
					print(player.Name, "Suspected to Fly Hacking")
				end
			end
		end
	end)
end)

Note that it is not tested so there may be minor bugs and values may need tweaking

1 Like

Is it possible you could explain each part of the script?

Sorry If I’m asking for too much.

the functions are pretty straight forward so I won’t explain that. Basically when a player joins it basically runs to check if the player is falling or ragdolling. if both are false then it checks if player is running or jumping too fast or is too high above the ground then uses that data to determine if their flying. note that I have not taken account of dying.

Alright, I’ll test it out and fix it to my needs and I’ll let you know how it goes.

Thanks for the help. :+1:

Most exploits uses a BodyVelocity to make exploiters fly. To prevent exploiters flying you could check if characters have a BodyVelocity inside of it.

I believe humanoid states are replicated from the client, so a cheater could just not send those states. It’d be better to use constant rays on the server and check from there. It gets more complicated when things like flinging and weird physics events gotta be considered.

1 Like

Exploits are client sided so thats unrealistic.

I was checking to see if the player was flung from some glitch in the game or was like falling.