How to make a anti fly?

I need an anti-fly. Unfortunately, every anti-fly I’ve made either doesn’t work, or if it does, it’s detected by something like jumping or falling from somewhere.
Please, if anyone knows a good example, send it to me.


local Players = game:GetService("Players")

return function(AntiCheat, Settings)
    Players.PlayerAdded:Connect(function(player)
        player.CharacterAdded:Connect(function(character)
            while task.wait(0.5) do
                local rootPart = character:FindFirstChild("HumanoidRootPart")
                if rootPart and rootPart.Position.Y > Settings.MaxFlyHeight then
                    AntiCheat.KickPlayer(player, "Flying detected")
                    break
                end
            end
        end)
    end)
end

You could just wait until server authority comes out. It’s going to prevent fly hacking