# Variable/frame problem :(

**URL:** <https://forum.kirupa.com/t/variable-frame-problem/169670>\
**Category:** Uncategorized\
**Created:** [November 18, 2005, 5:49am UTC](https://forum.kirupa.com/t/variable-frame-problem/169670 "2005-11-18T05:49:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kpxnamja](https://avatars.discourse-cdn.com/v4/letter/k/7c8e57/32.png) [@kpxnamja](https://forum.kirupa.com/u/kpxnamja)\
**Post date:** [November 18, 2005, 5:49am UTC](https://forum.kirupa.com/t/variable-frame-problem/169670/1 "2005-11-18T05:49:48Z")

</div>

Hi there, it’s my first time actually posting on kirupa 🙂  
Well here’s the dilemna…  
I’m planning to make a small rpg game involving with many fram jumping.

Here’s my problem.  
I already defined a Hit point variable as “hp”  
On my action layer i put.

```auto
hp = 50;

```

Then once the hero is attacked by the enemy, the enemy has a code inscribed:

```auto
_root.hero.gotoAndPlay("hit"); 
_root.hp = _root.hp -= (25 + random(5));

```

now… the problem… I put on my first frame of my action layer the action

```auto
 if (hp < 0)
gotoAndPlay("LOSE");

```

The hero ends up having -12323 and is still fighting the unbeatable enemy… Is the code incorrect? I tried to make the battle scene jump to the “lose” screen, but no luck… any help?

thanks!
