Attempt to index boolean with 'Changed'

So i have been trying to prevent code being executed until my character lands. So i used a function to return a true or false value to determine this

local function IsJumpingListener(Humanoid)
	local landed  = false
		if NewState == Enum.HumanoidStateType.Landed then
            landed = true
			landed = false
	return landed

Then i would use this code to wait till the character lands, however

 if not IsJumpingListener(humanoid) then IsJumpingListener(humanoid).Changed:Wait() end

I kept on getting this error

Any solutions? thanks

The reason this is happening is because in that function you’re returning the landed boolean, not the event. Try this:

 if not IsJumpingListener(humanoid) then repeat wait() until IsJumpingListener(humanoid) end

I’ve heard that we should avoid using that wait

Any alternative

It’s not the most efficient solution, but it’ll work.
You can also use RunService.Heartbeat, or make something similar to the thread you linked

Ok so the error stops coming but the code that I initiate after does not work properly

thanks for your help though

I fixed the problem my self, just ended up shooting an event every time my character is in the landing state