# decreaseVars not working!

**URL:** <https://forum.kirupa.com/t/decreasevars-not-working/143596>\
**Category:** Uncategorized\
**Created:** [April 7, 2005, 7:43am UTC](https://forum.kirupa.com/t/decreasevars-not-working/143596 "2005-04-07T07:43:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oli\_G](https://avatars.discourse-cdn.com/v4/letter/o/f05b48/32.png) [@Oli\_G](https://forum.kirupa.com/u/Oli_G)\
**Post date:** [April 7, 2005, 7:43am UTC](https://forum.kirupa.com/t/decreasevars-not-working/143596/1 "2005-04-07T07:43:13Z")

</div>

Hi guys, cant get this function to work!! heres the code. Apparently its fine, but when i open the trace output window, the variables dont change!!!

```auto
 stop();
  gilbertPlay = 3;
  gilbertHealth = 3;
  function decreaseVars() {
      // subtract 1 from gilbertHealth
      gilbertHealth--;
      // check if gilbertHealth is 0 and if so, kill
      if (gilbertHealth == 0) {
          _root.gotoAndStop(35);
      }
      // same for other vars
      gilbertPlay--;
      if (gilbertPlay == 0) {
          _root.gotoAndStop(35);
      }
  }
  setInterval(decreaseVars, 5000);
  rattle_mc.onRelease = function() {
      rattle_mc.play();
      eyes_mc.gotoAndPlay(28);
      gilbertPlay++;
      // if gilbertPlay var = 4
      if (gilbertPlay == 4) {
          // set gilbertPlay var to 3
          gilbertPlay = 3;
      }
  };
  bandaid_mc.onRelease = function() {
      bandaid_mc.play();
      gilbertHealth++;
      // if gilbertHealth var = 4
      if (gilbertHealth == 4) {
          // set gilbertHealth var to 3
          gilbertHealth = 3;
      }
  };
  healthStatus_mc.gotoAndStop('hc'+gilbertHealth);
  playStatus_mc.gotoAndStop('pc'+gilbertPlay);
  trace(gilbertPlay);
  trace(gilbertHealth);

```

cheers!
