Best way to prevent flying, noclip, and teleportation exploits?

What is the best way to stop flight, noclip, and tp exploits?
All answers and info is appreciated! Thanks in advance! :slightly_smiling_face:

4 Likes

for flight just do a loop checking are they in contact with the part bellow them for teleportation just do a loop of checking how far the player has moved every second and put an if statement to check is it above a certain distance then kick the player(idk about noclip though)

1 Like

But if a player jumps and falls for a long time, it’ll be counted as flying.

3 Likes

Check the humanoid state. Also you might want to stop swim fly by checking if they are in contact with water or not and they have not touched the ground. Anti-cheat is a big job!

1 Like

Yeah I have an anti-teleport in place. But the anti-flight you mentioned isn’t a viable method as Kdude mentioned if someone is falling (or if they lag / tab-freeze) it will get them punished.

Best way to stop flight or fling: if any bodygyros, bodyangularvelocities, bodyvelocities, or bodythrusts are present anywhere in the character on client, send to server and if server does not see the same thing, ban

there is no false positive to this unless you plan on using those on localscripts

any client checks can just be bypassed by an exploiter with ease.

that’s why you protect it with an anti-delete so the remote isn’t avoided from being called, i won’t get into details on how since I haven’t fully prepared one yet, however client checks still have to be done regardless otherwise you get massive false positives

anti-deletes dont work as the exploiter can simply change the scripts contents from what I’ve been told.

The server wouldn’t be able to detect most changes to the HumanoidState, doing so in the client would be dangerous.

1 Like

Not true, all client-sided anti exploits are unreliable, they can be deleted and manipulated. Even if you did happen to have two LocalScripts checking each other’s existence, they could just delete both simultaneously or manipulate the code within them then destroy them.

1 Like

In my opinion, the best way of detecting flying/teleporting on the server is to do magnitude checks. This is where you take the position of the HumanoidRootPart or the Torso, then again the next second or so. Then you can determine whether to kick the player by working out if they’ve travelled farther than they can normally walk.

The way you script this varies on what kind of game you’re making and might have to make necessary checks, here’s an edited version of the magnitude check I use in my games:

local players = game:GetService("Players")
local humanoidStates = {0, 3, 5, 7, 8, 10, 12, 15}

function loadChararacter(player)
	while true do
		local a, e = pcall(function()
			if not player.Character then return end
			local root = player.Character:FindFirstChild("HumanoidRootPart")
			local humanoid = player.Character:FindFirstChild("Humanoid")
			if not root or not humanoid then return end
			local previousPosition = root.Position
			local previousState = humanoid:GetState()

			delay(1, function()
				if not player.Character then return end
				if not root or not humanoid then return end
				if (root.Position - previousPosition).Magnitude >= 0 then -- 0 is how many studs the player gets to travel before getting kicked, increase this number if you get false positives.
					wait(0.1)
					if table.find(humanoidStates, humanoid:GetState().Value) or table.find(humanoidStates, previousState.Value) then return end -- Checks if player is falling.
					if humanoid.FloorMaterial ~= Enum.Material.Air or humanoid.Health == 0 then return end -- Checks if player is falling or dead.
					player:Kick(string.format("You just travelled %s studs in 1 second, kinda sus bro.", math.round((root.Position - previousPosition).Magnitude)))
				end
			end)
		end)

		if not a then
			print(string.format("anti exploit error: %s", tostring(e)))
		end

		wait(1)
	end
end

players.PlayerAdded:Connect(function(player)
	if player.Character then loadChararacter(player) end
	player.CharacterAdded:Connect(function(character)
		loadChararacter(player)
	end)
end)
1 Like

How does this work with vehicles which can carry you faster than walk/run speed?

1 Like

Sure that some exploits had a cframe fly, and some tween hacks which prevents script from checking due to a distance of traveling.

1 Like

Yeah this is something similar as to what I have in place to prevent speed / flying.
maybe the best way is to constantly check a players location and how high they are above ground. If they are midair then calculate how long it SHOULD take to hit the ground based on distance. Obviously laggy players would probably come down slower which is why the calculation should take that into consideration. I would already have an anti-speed in-place ontop of this so I wouldn’t need to check if they are flying around but rather how long they stay midair to determine if they are flying.

Obviously false positives can come out from this but its fairly uncommon and I wouldn’t ban people for being midair too long. Probably just kick.

I could also get the Y coordinate of the player constantly and check when it goes up to determine when a player ascends. If they ascend at an unrealistic speed I would kick them.

But what would be the best way to prevent noclip? Thats the main problem that stumps me. I’ve seen games with incredible anti-noclip but I dont really know how its done.