Need Help Optimizing an Anti-Fly-Exploit

My game has been the target of fly exploits recently. From what I have seen from players reporting kids doing it, it hasn’t been the worst, albeit the exploiters can fly across the map and kill players from angles that make it hard to counter them.

I’m currently working on an anti-exploit system for this, however, I don’t know how to make it fool-proof. It seems the only way I can get it to work is to have it detect when a player inserts BodyGyro or something similar into their character from the client, however, an exploiter can delete this script.

I tried the following in a server script located inside the Character via StarterCharacterScripts:

local char = script.Parent
function checkIfBody(part) --- this checks for it being inserted into a character part.
--- my game has vehicles and what not in it, so I don't want it to trip
--- when a player could simply just be using a vehicle.
	local result = false
	local parts = {
			"Head",
			"HumanoidRootPart",	
			"Left Arm",
			"Left Leg",
			"Right Arm",
			"Right Leg",
			"Torso",
	}
	for list,names in pairs(parts) do
		if part.Name == names then
			result = true
		end
	end	
	return result
end

char.DescendantAdded:Connect(function(new)
	local hum = char:WaitForChild("Humanoid",10)
	if new:IsA("BodyGyro") then
		if checkIfBody(new.Parent) == true then
			if plr:GetRankInGroup(1049814) < 201 then --- moderators in my game are allowed to fly because they have admin commands
				potentialExploiter(plr,"possibly using fly exploits.")
--- above line works. i am simply trying to log potential exploits before i utilize this script for punishment
			end
		end
	end
end)

This above code does not activate when a player inserts BodyGyro into their character part. I had a staff member of mine help me test, as I don’t use exploits myself nor want to.

This script, inserted into PlayerGui, worked.

local Character = LocalPlayer.Character
Character.DescendantAdded:Connect(function(new)
	local hum = Character:WaitForChild("Humanoid",10)
	if new:IsA("BodyGyro") then
		if checkIfBody(new.Parent) == true then
			if LocalPlayer:GetRankInGroup(1049814) < 201 then
				print(LocalPlayer.Name.." is exploiting!!!")
				warn(LocalPlayer.Name.." is exploiting!!!")
				print(LocalPlayer.Name.." is exploiting!!!")
				warn(LocalPlayer.Name.." is exploiting!!!")
				print(LocalPlayer.Name.." is exploiting!!!")
				warn(LocalPlayer.Name.." is exploiting!!!")
--- spam that message a few times so its easy for my helper to see it
			end
		end
	end
end)

How would I be able to detect players using fly exploits without them being able to delete the script does so? I’m pretty sure the options for the server to detect client behavior are very limited if not impossible, but detecting on the client itself isn’t reliable either due to them being able to delete it.

I believe client sided anti exploits are somewhat pointless as they don’t end up “stopping exploiters”, more so delaying them and being a hindrance to both you and them. Now, the only option you realistically have is to do checks on the server, which is more straightforward than it seems.

To begin with, you can make sure they’re not flying by casting a ray x amount of studs below them, and if the ray returns nothing for, lets say 5 seconds, they might start to take damage until they eventually die and/or get kicked. You can also check the logistics of a player killing another by doing multiple ray checks in a circle, distance, etc, just make sure you don’t make it too strict and accidentally ban people for shooting from towers.

How would this work in regard to the “void” of ROBLOX? My game is a bunch of islands separate from each other, so the flier would be over the void much of the time flying.

If you have any Seats on the map, then the anti-cheat is pointless

even if you implement a decent script client protection

If you have a void it makes it even easier to spot the cheaters, as if they’re flying over the void then there rays wont hit anything and will be detected, unlike if they were flying close to buildings.