Attempt to index applyForce a nil value error

Occasionally, I get the error shown at the end of this video:

https://www.youtube.com/watch?v=snztzAPsS84&feature=youtu.be

The error points to line 189:

function endJump() character:applyForce(0, 0, character.x, character.y) -- Line 189 end

The function is only used for the player’s jumps:

function touchScreen(event) if (event.phase == "began") then if (vy \> -25 and vy \< 25) then character:applyForce(0, -85, character.x, character.y) timer.performWithDelay(500, endJump, 1) end end end

I cannot get rid of this function because my character will go flying of the screen. Any help would be appreciated.

Sincerely,

Alex

This looks like a case of where you ran out of lives and destroyed character without cleaning up actions that character is still trying to perform.

Rob

I believe the applyForce problem has been solved:

function endJump() if character ~= nil then character:applyForce(0, 0, character.x, character.y) else end end

Thank you Rob.

This looks like a case of where you ran out of lives and destroyed character without cleaning up actions that character is still trying to perform.

Rob

I believe the applyForce problem has been solved:

function endJump() if character ~= nil then character:applyForce(0, 0, character.x, character.y) else end end

Thank you Rob.