Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Detecting if a player is falling?

This is a script inside StarterCharacter, a normal script. I'm trying to print something but for some reason this script isn't working. Any ideas?


local Humanoid = script.Parent:WaitForChild("Humanoid")

Humanoid.StateChanged:Connect(function(PreviousState, NewState)
	if NewState == Enum.HumanoidStateType.FallingDown then
		print("falling")
	elseif NewState == Enum.HumanoidStateType.Landed then
		print("landed")
	end
end

4 comments

0

I’ve edited the answer, try it out and see if it works.

0

hello?

0

use Run Service instead

0

also you forgot to change end to "end)" at the end

2 answers

✓ Accepted answer
local Humanoid = script.Parent:WaitForChild("Humanoid")
local RunService = game:GetService("RunService")

RunService.Heartbeat:Connect(function()
    if NewState == Enum.HumanoidStateType.FallingDown then
        print("falling")
    elseif NewState == Enum.HumanoidStateType.Landed then
        print("landed")
    end
end)

honestly i think this would work

but if it doesnt maybe you should check if the falling animation is playing instead

3 comments

0

You don't use falling down. You use free falling

0

I went into the animation script and it's literally as easy as: Humanoid.FreeFall:Connect

0

thank you all though.

I’ve edited it now, try this:

Instead of FallingDown do Freefall, which make should Line 4 look like:

if NewState == Enum.HumanoidStateType.Freefall then

Hopefully this works out for you :D

2 comments

0

Air doesn't seem to work, I've tried using this method with ==nil, every material, " " but nothing seems to work :(

0

try Air with no " " and see what it does

This discussion is preserved as it was. New answers, comments, and votes are closed.