How do you make anti fly with an ocean + elevation?

I have large mountains in my game, and an ocean which is a mesh and doesn’t have part detection for raycasting. How exactly can I prevent players from false positives in this case?

Anti-Fly Script Part:

local foundPart = workspace:Raycast(root.Position, CFrame.new(root.Position, root.Position-Vector3.new(0,1,0)).LookVector*25, params)
local foundPart2 = workspace:Raycast(root.Position, CFrame.new(root.Position+root.CFrame.LookVector*5, (root.Position+root.CFrame.LookVector*5)-Vector3.new(0,1,0)).LookVector*25, params)
local foundPart3 = workspace:Raycast(root.Position, CFrame.new(root.Position-root.CFrame.LookVector*5, (root.Position-root.CFrame.LookVector*5)-Vector3.new(0,1,0)).LookVector*25, params)

if foundPart and not foundPart.Instance and foundPart2 and not foundPart2.Instance and foundPart3 and not foundPart3.Instance or hum.FloorMaterial == Enum.Material.Air then
	if not char:GetAttribute("Swimming") and not char:GetAttribute("Fly") and not char:FindFirstChild("FallDebuff") then
		if play.DevilFruit.Value ~= "Kilo" and not root:FindFirstChild("PawTransport") then
			if Warns < MaxWarns then
				if root.Position.Y > workspace.Ocean.Position.Y + 60 or hum.PlatformStanding then
					if hum.FloorMaterial == Enum.Material.Air then
						if (hum:GetState() == Enum.HumanoidStateType.PlatformStanding) and not char:GetAttribute("Ragdoll") then
							Warns += 2
							currentreason = "Fly Hacks"
						else
							if not char:GetAttribute("Ragdoll") then
								Warns += 1
								currentreason = " Fly Hacks"
							end
						end
					end
				end
			end
		end
	else
		Warns = 0
	end
else
	Warns = 0
end
1 Like