I’m trying to make an Anti-Fly script (server side) by checking the HumanoidRootPart's position on the Y axis, and if there in the air higher then they can jump for a certain amount of time, I respawn them, but I’m not sure how I would go about making this, I cant just check the Y value too see if its too high, because that can cause too many false positives…
There is only two things you can check server side that is velocity and position.
I am almost certain there is no other way…unless the HumanoidStateTypes are replicated which they probably aren’t and you could get around that by disablign them too.
You might just want to put an kick system and report system in place. much easier to do
I don’t even think you can, phantom forces also has tons of people using that right now. It would be pretty cool is roblox just gave us access to the tweens in tweenservice, to simply compare whats running in tweenservice to what we actually want.
There is a way to detect it using a zone script, obviously, you know they can’t reach certain areas, if you were to mark all the areas they could touch (including a little bit off of cliffs in case they jump off) then a flying person would get flagged if they somehow exited the area.
If you choose this option I highly recommend you check out zoneplus V2
The only way I could think of doing this without using zones is checking for nearby cliffs using a ray to the nearest cliff, however this seems like a worse solution than simply running zones
I’m aware that’s what you mean, but regardless the only way you could avoid the aforementioned false positives is to check If they jumped off a cliff, which is why you would check if there is a nearby cliff.
Make a raycast down, and compare the position.
Like this;
local RaycastDown = workspace:Raycast(self.Character.HumanoidRootPart.Position,Vector3.new(0,1,0) * -250,Params)
if (RaycastDown) then
if (self.Data.LastFlyPosition) then
local DifferenceY = (self.Character.HumanoidRootPart.Position-self.Data.LastFlyPosition).Y
if (DifferenceY > self.Humanoid.JumpHeight * 1.2) then
self:Kick('Flying')
elseif (math.floor(DifferenceY) == 0) then
self.Data.LastFlyPosition = self.Character.HumanoidRootPart.Position
elseif (DifferenceY < 0) then
self.Data.LastFlyPosition = self.Character.HumanoidRootPart.Position
end;
else
self.Data.LastFlyPosition = self.Character.HumanoidRootPart.Position
end;
end;
Here is a piece of an anti-exploit I made, hope it helps
With the current set of tools available to developers, its hard to do this.
Personally, I would keep track of the last highest position they had the last time they were on the ground (You can use FloorMaterial and/or raycasting for this, record it every heartbeat or something) and then compare it to where they are in the air at each interval.
From what I’ve seen and used, you can connect an anti fly check function to heartbeat to run every 0.2-0.5 seconds.
Some ways to do this include:
compare last primary part positions in the y axis
raycast a certain distance down to validate if they are on the floor or in the air.
(i’ve never done this, but just an idea) region3 to detect any parts around the character (filtering its descendants) - no parts detected would mean they are in the air
These methods may be performance intensive so having a good interval (not to small, not to high), between checks is important.
The problem though lies within false positives. You could try having a maximum amount of flags, make it high, and if they have been detected multiple times, you could then respawn them or teleport them back. This can stop many false positives such as falling. Important: make sure that after each flag or exploit detected, have a 7-10 second (or however high you want it) cooldown before the next check.