If statement for if player is in air roblox studio

Hello, i need to check whether or not the player is in the air on activation of something. I know how to check using staechanged but i need it to only be an if statement

Hi there, you would need to use the Humanoid and check what state it is in, for example:

if Humanoid:GetState() == Enum.HumanoidStateType.FallingDown then
     -- whatever you want to happen
end

That should work.

if Humanoid:GetState() == Enum.HumanoidStateType.FallingDown then
				print("falling")
			else
				print("not falling")
			end

It doesnt work, it doesnt print

Are you checking it when the Humanoid state changes?

No. The player presses a button and if they are in the air it prints that they are in the air and viceversa

Well, you could try FreeFalling instead of FallingDown, or another method is to just check the position of the HumanoidRootPart for example, if it’s more than X studs on the Y axis then you could tell they’re in the air

I know this has been solved, but a more reliable solution could to be to use FloorMaterial. FloorMaterial is self explanatory, but it will return Enum.Material.Air (or just nil/""). Try using that.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.