Enter Frame function doesn't work

[lua]

local function hpDetection(event)

    if hp == 0 then

      composer.gotoScene(“scenes.lobby”)
      physics.removeBody(zombie)
      physics.removeBody(hero)
      zombie:removeSelf()
      hero:removeSelf()
      Joystick:removeSelf()
      AttackButton:removeSelf()
      hp:removeSelf()
      map:removeSelf()

    end

  end

  Runtime:addEventListener(“enterFrame”,hpDetection)

[/lua]

Why that doesn’t work?

What do you mean it doesn’t work?

https://forums.coronalabs.com/topic/55780-ask-a-better-question-get-a-better-answer/

Call me paranoid, but I’m getting the feeling hp is never zero.

That’s probably the case, and adding a “<= 0” might fix that, but I expect that once that check is cleared, then it’ll run into a runtime error the very next frame.

I mean when hp is 0 nothing happens

Then I add “<= 0” I get an error

What kind of error? Did you include the quotation marks there too, because that’d lead to an error too.

The easiest way to get help is to provide us with a small sample project that demonstrates your issue. Based on the code you’ve shared, we can only guess. It might seem like plenty, but we don’t know what the error is, we don’t know what problems you are facing, we don’t know anything for certain when it comes to what you’ve shared.

Help us help you. Create a small project that demonstrates your issue so that we can help you debug it.

I found a mistake! I needed to add hero.hp not hp.

That’s a perfect example of a “problem with my code” that no one else could have figured out in a million years.

What do you mean it doesn’t work?

https://forums.coronalabs.com/topic/55780-ask-a-better-question-get-a-better-answer/

Call me paranoid, but I’m getting the feeling hp is never zero.

That’s probably the case, and adding a “<= 0” might fix that, but I expect that once that check is cleared, then it’ll run into a runtime error the very next frame.

I mean when hp is 0 nothing happens

Then I add “<= 0” I get an error

What kind of error? Did you include the quotation marks there too, because that’d lead to an error too.

The easiest way to get help is to provide us with a small sample project that demonstrates your issue. Based on the code you’ve shared, we can only guess. It might seem like plenty, but we don’t know what the error is, we don’t know what problems you are facing, we don’t know anything for certain when it comes to what you’ve shared.

Help us help you. Create a small project that demonstrates your issue so that we can help you debug it.

I found a mistake! I needed to add hero.hp not hp.

That’s a perfect example of a “problem with my code” that no one else could have figured out in a million years.