Well I’ve made a simple server sided anti fly. It uses checks to find ground underneath the player with some calculation done to account for jumping and falling from high places, But this would also mean that the higher the game takes place, the less effective this become, So use it in a grounded game, Like some pet simulator, And NOT some Everest climbing game
PS.There is no punishment in the script, Add one in the punish function, such as set the health to zero or such.
script:
Expand
--Contants
--local Events = script.Events
--Complicated stuff ask tin_nim for some explaination.
local suslist = {}
local function punish(plr)
--DO some punishment here
end
local function lerp(x)
return (0.045*x)+2
end
local function ProcessFuction(player,heighti)
local height = (player.Character.Humanoid.JumpPower ^ 2) / (2 * workspace.Gravity)
height = heighti or height + player.Character.PrimaryPart.Position.Y
local velocityStart = math.sqrt(height * 2 * workspace.Gravity)
local Airtime = ((2 * velocityStart) / workspace.Gravity)
local distance = (Airtime * player.Character.Humanoid.WalkSpeed) - lerp( player.Character.PrimaryPart.Position.Y-player.Character.Humanoid.HipHeight)
return {distance,Airtime,velocityStart,height}
end
local function coherentCheck(player)
--print(suslist)
if player.Character then
local raycastparam = RaycastParams.new()
raycastparam.FilterType = Enum.RaycastFilterType.Blacklist
raycastparam.FilterDescendantsInstances = {player.Character}
local result= workspace:Raycast(player.Character.HumanoidRootPart.Position,Vector3.new(0,-100,0),raycastparam)
local result1 = workspace:Raycast(player.Character.HumanoidRootPart.Position,Vector3.new(-20,-100,20),raycastparam)
local result2 = workspace:Raycast(player.Character.HumanoidRootPart.Position,Vector3.new(20,-100,20),raycastparam)
local result3 = workspace:Raycast(player.Character.HumanoidRootPart.Position,Vector3.new(-20,-100,-20),raycastparam)
local result4 = workspace:Raycast(player.Character.HumanoidRootPart.Position,Vector3.new(20,-100,-20),raycastparam)
if not (result or result1 or result2 or result3 or result4)then
print("NORES")
if suslist[player.UserId] then
if ProcessFuction(player,suslist[player.UserId][1])[2] < tick() - suslist[player.UserId][2] then
punish(player)
else
return
end
end
suslist[player.UserId] = {player.Character.HumanoidRootPart.Position.Y,tick(),100}
else
if (result.Distance > 10) and (result1.Distance > 10) and (result2.Distance > 10) and (result3.Distance > 10) and (result4.Distance > 10) then
print("RES>10")
if suslist[player.UserId] then
print("PREDICTION"..ProcessFuction(player,suslist[player.UserId][1])[2])
print("RESULT "..tick() - suslist[player.UserId][2])
if ProcessFuction(player,suslist[player.UserId][1])[2] < tick() - suslist[player.UserId][2] then
punish(player)
else
return
end
end--cfg then
suslist[player.UserId] = {player.Character.HumanoidRootPart.Position.Y,tick(),result.Distance}
else
if suslist[player.UserId] then
suslist[player.UserId] = nil
end
end
end
end
end
local function Init(player)
local connection
player.CharacterAdded:Connect(function()
spawn(function()
while task.wait(1) do
if not game.Players:GetPlayers(player.Name) then
break
end
coherentCheck(player)
end
end)
end)
end
game.Players.PlayerAdded:Connect(Init)