# Having trouble in attacking

**URL:** <https://forum.kirupa.com/t/having-trouble-in-attacking/80397>\
**Category:** programming\
**Created:** [February 21, 2005, 11:33pm UTC](https://forum.kirupa.com/t/having-trouble-in-attacking/80397 "2005-02-21T23:33:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ar1](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@ar1](https://forum.kirupa.com/u/ar1)\
**Post date:** [February 21, 2005, 11:33pm UTC](https://forum.kirupa.com/t/having-trouble-in-attacking/80397/1 "2005-02-21T23:33:07Z")

</div>

I want it to where when I press space a clip in a certain distance in front of me would be hit, with a simple knife thing.

This is the coding that I have for the character

onClipEvent (load) {  
stop()  
movespeed = 7;  
stagewidth = 550;  
stageheight = 400;  
}

onClipEvent (enterFrame) {  
if (Key.isDown(Key.RIGHT)) {  
if(this.getBounds(\_root).xMax \< stagewidth) {  
\_x+= movespeed;  
} else {  
\_x = stagewidth-(\_width/2);  
}  
}  
if (Key.isDown(Key.LEFT)) {  
if(this.getBounds(\_root).xMin \> 0) {  
\_x-= movespeed;  
} else {  
\_x =(\_width/2);  
}  
}  
if (Key.isDown(Key.RIGHT)) {  
wasRight = true;  
this.gotoAndStop(2)  
} else if (Key.isDown(Key.LEFT)) {  
wasRight = false;  
this.gotoAndStop(3)  
} else {  
if(wasRight) {  
gotoAndStop(1);  
} else {  
this.gotoAndStop(4);  
}  
}  
}

I want an

if (Key.isDown(Key.SPACE)) {  
at a close distance  
if hit  
then movie clip is gone

that kind of thing

can someone help me
