Enum.HumanoidStateType.Landed does not work consistently

I’m trying to implement fall damage in my game, and I’m using Enum.HumanoidStateType.Landed to check when the player has landed. The problem is that half of the time the script doesnt detect that the player landed. Here is an example of what is happening:

here is the script not working:
https://gyazo.com/0a90d5dcaf643886eb4fd643f1ea0daa

here is the script working:
https://gyazo.com/f5dc8c9e9464eb7dfe3ffabbf6914ea1

and here is the script I used:

local Ragdoll = require(game.ReplicatedStorage.Modules.Ragdoll)
local players = game.Players




players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(plr)
		local hum = plr.Humanoid
		local HRP = plr.HumanoidRootPart
		local falling = false
		local fallcount = 0
		local startpos
		
		hum.StateChanged:Connect(function(oldstate,newstate)
			if newstate == Enum.HumanoidStateType.Freefall then
				startpos = HRP.Position.Y
				hum.JumpPower = 0
			elseif newstate == Enum.HumanoidStateType.Landed then         
				local endpos = HRP.Position.Y
				if (startpos - endpos) >= 15 then
					hum.Health = hum.Health - ((startpos-endpos)/2)
					Ragdoll(player.Character, true)
					wait(3)
					Ragdoll(player.Character, false)
				end
				wait(1)
				hum.JumpPower = 50
			end 
		end)
	end)
end)

Thanks in advance for any help!

Try to diagnose and print the humanoid states to observe how the humanoid changes from the time it spawns to the time it “lands”. It is possible that the engine physics are interfering with the script somehow or the humanoid is at faulty.

1 Like

Thanks! this helped me a bunch

I know this is a little late but, what exactly did you do to fix it? I’ve been having this problem for a while and can’t seem to figure it out.

3 Likes

2 years later and this still is a problem, I think the only solution is to check if the last state was free falling and then cast a ray downward to check if their on the floor.