Raycast Issue with testing if the character is in the air or not

I’m trying to detect whether or not the character is in the air or on the ground, however. Every time I try to do this it always say im on the ground when I’m very much higher then 3 studs in the air.

Video Attached showing that I’m well above 3 studs.


local player = game.Players.LocalPlayer

local Character = player.Character or player.CharacterAdded()
local HumRP = Character.HumanoidRootPart

local NewRaycastParams = RaycastParams.new()
NewRaycastParams.FilterType = Enum.RaycastFilterType.Exclude
NewRaycastParams.FilterDescendantsInstances = {Character, game.Workspace.SpawnLocationMain}
					
local direction = Vector3.new(0,-3,0)
				
local RayCast = workspace:Raycast(HumRP.Position, direction, NewRaycastParams)

if RayCast then
print("Ground")
end

if not RayCast then
print("Air")
end

You don’t need a raycast to test whether a player is on the ground. The humanoid has a property called FloorMaterial, if it is air then the player isn’t on the ground. You could also use Humanoid:GetState() but that may be slightly more complicated.