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)```
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.
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.
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.
@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
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.
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
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?
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.