Why does my anti-fly exploit not work when server-sided?

Hello! Recently I came across a problem with a script of mine.

image

I have a local script that basically kicks out exploiters that attempt some flying methods…

local Username = script.Parent.Parent.Parent.Name
local Player = game.Players:FindFirstChild(Username)
local Character = game.Workspace:FindFirstChild(Username)
local HumanoidRootPart = Character:WaitForChild ("HumanoidRootPart")
local UpperTorso = Character:WaitForChild ("UpperTorso")
local LowerTorso = Character:WaitForChild ("LowerTorso")

HumanoidRootPart.ChildAdded:Connect(function(Object)
	if Object.ClassName == "BodyGyro" or Object.ClassName == "BodyPosition" or Object.ClassName == "BodyVelocity" then
		Object:Destroy()
		Player:Kick("Kicked due to unexpected client behavior")
	end
end)

UpperTorso.ChildAdded:Connect(function(Object)
	if Object.ClassName == "BodyGyro" or Object.ClassName == "BodyPosition" or Object.ClassName == "BodyVelocity" then
		Object:Destroy()
		Player:Kick("Kicked due to unexpected client behavior")
	end
end)

LowerTorso.ChildAdded:Connect(function(Object)
	if Object.ClassName == "BodyGyro" or Object.ClassName == "BodyPosition" or Object.ClassName == "BodyVelocity" then
		Object:Destroy()
		Player:Kick("Kicked due to unexpected client behavior")
	end
end)

Basically I would replace the local script with a server script for instance, and nothing would happen, I was reading my code and couldn’t figure out the reason, I even tried creating another script that Should make this work server-sided, and it still doesn’t work, any thoughts?

1 Like

If the BodyGyro/BodyPosition are being created on the client then the server won’t detect it.

1 Like

And here I was spending three hours thinking my code was broken, thank you.

1 Like