HumanoidStateType.Landed does not work half of the time

So, i want that when a player lands it prints

but when the player lands, half of the time its does not print, sometimes it prints and sometimes not…/

this is the code…

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        local humanoid = char:WaitForChild("Humanoid")
        humanoid.StateChanged:Connect(function()
            if humanoid:GetState() == Enum.HumanoidStateType.Landed then
                print("Landed")
            end
        end)
    end)
end)

Please, if someone can tell me the problem it will be helpfull

Once the character is loaded, the script will immediately check if the player is landed or not. If they are not landed by the time the script checks, the script will have ended. Try using a loop to keep checking until it has landed.

repeat
wait()
until humanoid:GetState() == Enum.HumanoidStateType.Landed
print(“Landed”)

Ok!, thank you!!!
i will try it out now

local U = 1

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local debounce = false
		local humanoid = char.Humanoid
		humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
			if humanoid.Jump == true then
				wait(1)
				if humanoid.Jump == true then
					humanoid.StateChanged:Connect(function()
						if humanoid:GetState() == Enum.HumanoidStateType.Landed then
							if debounce == false then
							debounce = true
							wait(0.2)
							
							print("Jumpin")
							
							if player.Areas.AgilityArea.AgilityAreaMulti.Value == true then U = 5 -- 100 Agility required

							else U = 1

							end

							local GainAgility = ((1 * player.realMultiplayers.AgilityMultiplayer.Value) * (U))

							player.RealStats.Agility.Value = ((player.RealStats.Agility.Value) + GainAgility)

								debounce = false
							end
						end
					end)
				end
			end
		end)
	end)
end)

this is my full code, it need to detect if player jump for 1 second then it wait for the player to land and give him stats, it will have the same problem too?

It will only work if the player lands at exactly 1 second, else the if condition will not be true. The script would not wait until it is true and just run past it.

So, how i can fix that??
Btw thank you for helping me

You could use a repeat loop again to keep checking until it lands, or you could use a .Changed event on the humanoid.