Anti exploit not working?

Hello, i made this anti exploit script for my game, and i saw someone fly about? Im confused.
Edit: This script is in Starter Gui.

CODE:

local char = game.Players.LocalPlayer.Character
local plr = game.Players.LocalPlayer




char:WaitForChild("HumanoidRootPart",3).ChildAdded:Connect(function(c)
	if c:IsA("BodyMover") or c:IsA("BodyGyro") then
		game.ReplicatedStorage.FlyLog:FireServer()
		wait(2)
		plr:Kick("HACKING NOOB.")
		end
		end)```
1 Like

I’m unsure if scripts run in StarterGui.
If they do, an exploiter can simply delete this script, delete the remote, or disconnect the event.
Don’t rely on this to create a client anticheat.

2 Likes

Perhaps they’re using other ways to move their character. Instead, maybe have a way of checking their distance from the ground, or/and their speed.

Also, more importantly, why are you checking from a localscript?? Always do the checks in a server script, as anyone with exploits can access and mess with localscripts.

So, move this over to a server script, placed in serverscriptservice or something, and add extra checks. Let us know if you need help with that.

3 Likes

I dont not know how to check from a server script.

Because of local player and stuff.

Ah I see. So I’m sure there’re better ideas others have, but here’s one:

Get all of the players in the game with :GetPlayers(), and then do the checks on all of them. Perhaps repeat this cycle every few seconds or something. Like:

local Players = game:GetService("Players")

function checkPlayers()
    for i, player in pairs(Players:GetPlayers()) do
        -- Do checks here
    end
end

while true do
    checkPlayers()
    wait(5)
end

Keep in mind, I’ve never made an anti cheat before, but this should be the gist of it.

2 Likes

So i put the anti fly scrip in there

I am no good with english and script, im sorry :slightly_frowning_face:

@MJTFreeTime will this work local Players = game:GetService(“Players”)

function checkPlayers()
	for i, player in pairs(Players:GetPlayers()) do
		player.Character.HumanoidRootPart.ChildAdded:Connect(function(c)
			if c:IsA("BodyGyro") or c:IsA("BodyMover") then
				player:Kick("imagine hacking smh.")
			end
		end)
	end
end

while true do
	checkPlayers()
	wait(5)
end

How to what? And that script should work as intended - though you’ll want to re-evaluate if that’s the way you want to do the checks or not.

EDIT: Let me know if they’re any errors.

2 Likes

By the way, keep in mind that all you’re doing is checking if the players have a BodyMover or BodyGyro in them. The problem is that there could be other ways for exploiters to fly without either of these things.

Thus, it might be a good idea for you to do other checks, such as seeing how high above the ground the players are (if this game doesn’t involve being high above the ground), as well as their speed.

Oh yeah this is a big no. Just a waste of time.

3 Likes

Im confused, no matter how much i edit the script, it dosent return an error.

Really? That’s strange. You placed the script in serverscriptservice?

Make sure of the above first - but try this and tell me if they both print:

function checkPlayers()
	for i, player in pairs(Players:GetPlayers()) do
		player.Character.HumanoidRootPart.ChildAdded:Connect(function(c)
			if c:IsA("BodyGyro") or c:IsA("BodyMover") then
				player:Kick("imagine hacking smh.")
			end
		end)
	end
    print("Function Confirmed Fired!")
end

while true do
	checkPlayers()
    print("Function Called!")
	wait(5)
end

They are printing. I dont know why its not working.

Well them printing should mean it’s working.

And, well it’s not supposed to error, I was just checking. If it does error, that means there’s something wrong. But if it doesn’t error then it means that it’s working just fine, right?

Yeah, ive tryed flying using HD admin and it didnt kick the player.

Ah I see. So that’s likely a problem with the way you’re checking then.

Look at this reply I gave you earlier:

1 Like

This is useless, because It will only check on the server.

What exactly do you mean it’s useless because it’ll only check on the server? If you were to check on the client that would be the problem. Because exploiters can just delete/mess with the localscript.