Anti fly script always kicks u

hi, i was working at an Anti-Exploit sistem but im stuck at anti fly script, it kick the player everytime. The script:


coroutine.wrap(function()
	 if Main.FlyHack[1] == true then
	    while wait(0.1) do
			local Ingore = {}
			for _,Child in ipairs(Character:GetChildren()) do
			   if Child:IsA('BasePart') then
				    table.insert(Ingore,Child)
				end
			end
		    local r = Ray.new(Torso.CFrame.p,Vector3.new(0,-15,0))
			local hit,position,normal = workspace:FindPartOnRayWithIgnoreList(r,Ingore)
			if not hit then
			    Hacker(game.Players[Character.Name],'Fly')
			end
		end
	  end
	end)()

What is Hacker and Main? Please could we see those functions too.

1 Like

I can barely understand what is even happening in the script. Handling fly-hacks is a delicate and complex issue as it can be really hard to detect if someone is actually exploiting or just jumped off a high location or got flung.

One way some games handle them is by completely getting rid of anything that could cause a character to go in midair. Are they not on the ground? Kick them. Another similar way would be to plan your map so that the only way for them to end up in mid-air is by jumping, meaning you only need to check for how long they haven’t stood on the ground.

I would avoid using raycasting as a character can also stand on small blocks that could pass between the rays, causing false positives.

The way I would handle this is by checking their behavior on the Y axis. You can find suspicious players by checking if their acceleration suddenly rose without them being on the ground in the previous frame, or if their vertical velocity doesn’t change for over 2/3 frames without them standing/lying.

1 Like

in the script i use Ray Casting and if the Ray don’t hit something the script will kick him

in the game don’t exist ledges, the biggest thing is 6 studs and i detect if a hacker fly over 15 studs

oh, then how can i repair this?

Whilst raycasting can detect flying, it can quite often false positive. Many fly scripts use BodyGyros, BodyVelocities, BodyForces and BodyTorques. These are then usually placed inside the HumanoidRootPart as it is the only character part that can be moved without killing the player.

I suggest that you check for these objects inside the root part alongside Y axis checks and maybe raycasting.
This could quite easily seperate a fling from a player flying.

This is bad advice.

You can definitely put a BodyMover into different parts attached to the character and not “kill” their character. Furthermore, “raycasting” does not create false positives. It is the implementation of how you use that data which causes the false positives.

Local fly scripts create these objects on the client-side. Thus, they are not visible to the server, as they are not normally replicated from client->server. The only method of detecting if these residual instances exists are on the client. Recall from prior lecture that it is trivial for a malicious agent to simply disable these local checks. Furthermore, a determined individual could simply manipulate their local physics force without the need for such instances in memory.

1 Like

You forgot to check CanCollides of part.