ChildAdded doesn't works

I’m trying to do a server-sided anticheat with an anti-fly system.
So, I want to kick player when BodyVelocity has been added in HumanoidRootPart, but ChildAdded doesn’t works. The script don’t have any errors.
Script:

			game:GetService("Players").PlayerAdded:Connect(function(plr)
				repeat wait() until plr.Character
				wait(1)
				local humr = plr.Character.HumanoidRootPart
				while wait(1) do
					humr.ChildAdded:Connect(function(adde)
						if adde:IsA("BodyMover") or adde:IsA("BodyVelocity") or adde:IsA("BodyGyro") then
							adde:Destroy()
							wait(1)
                            print("it works!")
						end
					end)
				end
			end)	

Thanks!

Please do not use a loop when constructing/adding events. It will only increase the server workload. One event should be enough.

1 Like

I’m just going to assume that this is a ServerScript and you are adding it locally. Server does not detect what is made locally. And as @Quwanterz said, remove the while wait function. It will eventually cause the server to lag quite badly.

1 Like

Thanks! Also I will remove loop.