Anti Exploit Code is broken

I made a anti exploit script on server sided. Everything was going well until there was one major issue. When I step first on my map it automatically kicked me out. I checked the StarterPlayer to see if the player settings are correct and they are. I checked the gears they are what they suppose to. I don’t see what’s wrong with the code maybe you do if you do, please tell me below.

Here is some of the Code:

for i,Parts in pairs(workspace.World["Parking Lot Area"][".Spawn Areas. "]:GetChildren("SpawnLocation")) do
		if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
            local Ememy = Players:GetPlayerFromCharacter(hit.Parent)
            --- Humanoid Variable ---
			local Backpack = Ememy.Backpack
			local Starter = Ememy.StarterGear
			local Children = hit.Parent

			while wait() do -- Locks on a player and loops forever, until they do something illegal.
				Humanoid.Name = "Humanoid"
					if Ob:IsA("HopperBin") then
						Ememy:Kick("We meet again...")
				if Humanoid.WalkSpeed ~= 16 or Humanoid.JumpPower ~= 50 or #Children:GetChildren("ForceField") > 1 or #Children:GetChildren("Humanoid") ~= 1 or Humanoid.MaxHealth ~= 100 then																																							
					Ememy:Kick("attempt to index nil")

This is unrelated but it’s not a good idea to wrap event listeners inside of an infinite loop.
Every repetition creates a new connection and ends up wasting memory.

None of your conditions will ever be fired. Btools don’t replicate, meaning the server will never be able to see the HopperBin’s inside the player’s backpack. Same logic applies for the rest of the conditions.

1 Like

Can a Debounce solve the problem?

No, since that doesn’t solve

move it out of the loop and above it, and you’ll be :ok_hand:

1 Like

Some of your conditions also don’t make sense:

#Children:GetChildren("ForceField") > 1
#Children:GetChildren("Humanoid") ~= 1

You can’t “search” an instance with GetChildren this way. You need to call GetChildren then iterate through the result and count the number of instances of the class you want.

This is likely what was causing the false positives, because you are just comparing the number of children, not the number of children of a specific type.

Also, if this is running on the server, changes to the Humanoid properties will never be detected if we assume that exploiters are only changing them on their machines.