# Please help with code

**URL:** https://forum.kirupa.com/t/please-help-with-code/222426
**Category:** Uncategorized
**Created:** [April 13, 2007, 11:10am UTC](https://forum.kirupa.com/t/please-help-with-code/222426 "2007-04-13T11:10:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![slayerX2](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@slayerX2](https://forum.kirupa.com/u/slayerX2)
#### Post date: [April 13, 2007, 11:10am UTC](https://forum.kirupa.com/t/please-help-with-code/222426/1 "2007-04-13T11:10:02Z")

</div>

hello again, im having trouble with this code, hwat i want is when i press control it attacks rite? well when i wanna go up and kill a monster, i just hav to walk up to it to hurt it, how do i make it that i have to attack to hurt it, heres my line of code. PLEASE HELP

```auto
onClipEvent(load){
 gravity = 0.9;
 speed = 5;
 yspeed = 0;
    xspeed = 5;
 jumping = 0;
}
 
onClipEvent(enterFrame){
 
 if (Key.isDown(Key.LEFT)){
  this.gotoAndStop("Walk")
        this._x -= xspeed;
  this._xscale = 100
 
 }
 if (Key.isDown(Key.RIGHT)){
  this.gotoAndStop("Walk")
  this._x += xspeed;
  this._xscale = -100
 }
 if (Key.isDown(Key.CONTROL)){
  gotoAndStop("attack")
  if(this.hitTest(_root.enemy)){
        _root.hp -= (random(5)+1);
}
 }
 if ((Key.isDown(Key.SPACE)) and (!jumping)) {
  gotoAndStop("jump")
  yspeed = -5;
  jumping = 1;
 }
 
  yspeed += gravity;
        while (_root.terrain.hitTest(_x, _y+_height/2, true)) {
            _y--;
            yspeed = 0;
   jumping = 0;
        }
        if (!_root.terrain.hitTest(_x, _y+_height/2+1, true)) {
            _y += yspeed;
        } else {
            yspeed = 0;
   jumping = 0;
 
 
 
    }
} 

```
