local suspectedPlrs = {}
game:GetService("RunService").Heartbeat:Connect(function()
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
if v.Character then
if v.Character.Humanoid.FloorMaterial == Enum.Material.Air then
if not suspectedPlrs[v] then
suspectedPlrs[v] = os.time()
else
print(os.time() - suspectedPlrs[v])
local timeDifference = os.time() - suspectedPlrs[v]
if timeDifference >= 2 then
print("flying")
elseif timeDifference < 2 then
suspectedPlrs[v] = nil
print("not flying")
end
end
end
end
end
end)
I’m creating an anti-fly, but I ran into a problem. i need another conidition for my elseif to detect if they’re not just jumping. My original way was to just check if FloorMaterial was not set to air, but that wouldn’t work since I have this line at the top:
if v.Character.Humanoid.FloorMaterial == Enum.Material.Air then
Is there any way that I can rewrite this to allow for that?
You can detect this exploit by using the aforementioned method but the only difference is adding checks to the humanoid’s states. If there was a humanoid state lasting for many seconds, it would be impossible.
Technically, you can see that the player is falling by flying, thus the state is falling. However, their velocity is not truly downwards. Sometimes they are suspended in the air. It is expected that the player’s velocity is down affected by the gravity of the world.
I went on google and literally just searched “Fly script roblox” and about 90% of them are made by putting a BodyVelocity or a BodyGyro inside the HumanoidRootPart. So what would be reasonable is to check if any of those things is being added to the player’s HumanoidRootPart and if so you could kick them, example : (LocalScript)
game.Players.LocalPlayer.Character.HumanoidRootPart.ChildAdded:Connect(function(Object)
if Object.ClassName == "BodyGyro" or Object.ClassName == "BodyPosition" or Object.ClassName == "BodyVelocity" then
game.Players.LocalPlayer:Kick("Flying Exploit")
end
end)
Thanks for the suggestion. I believe there’s already an anti-exploit in my game in place that checks for bodymovers on the client (just in case any people that don’t really understand that they can bypass it try to do it). Unfortunately a lot of the exploiters that “visit” generally are smart enough to know how to disable it.
Most of the exploits that I have seen generally rely on setting the CFrame of HumanoidRootPart to avoid systems like these in the first place which is why I’m trying to rely on checking if they’re in the air.
I changed it to the way that you suggested. Thanks.
game:GetService("RunService").Heartbeat:Connect(function()
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
if v.Character then
if v.Character.Humanoid:GetState() == Enum.HumanoidStateType.PlatformStanding or v.Character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
if v.Character.HumanoidRootPart.Velocity.Y < 5 then
print("flying")
else
print("not flying")
end
end
end
end
end)
(i need to fine tune the velocity a little bit so that it doesn’t pick up jumping but overall it’s working so far)