# Shooting

**URL:** <https://forum.kirupa.com/t/shooting/185764>\
**Category:** Uncategorized\
**Created:** [April 16, 2006, 8:36am UTC](https://forum.kirupa.com/t/shooting/185764 "2006-04-16T08:36:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abstroose](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@abstroose](https://forum.kirupa.com/u/abstroose)\
**Post date:** [April 16, 2006, 8:36am UTC](https://forum.kirupa.com/t/shooting/185764/1 "2006-04-16T08:36:59Z")

</div>

Hey, I’m having a problem with a shooting script in my game. Basically I have the player1 MC and an MC with the instance bullet on my main keyframe.

Here is the code on the keyframe:

```auto
depthcounter=0
myListener = new Object();
no=1
max=20
myListener.onKeyDown = function() {
 if (Key.isDown(Key.CONTROL) and no<max) {
_root.bullet.duplicateMovieClip("bullet"+depthCounter, depthCounter)
 _root["bullet"+depthCounter]._x = p1._x
 _root["bullet"+depthCounter]._y = p1._y
 _root["bullet"+depthCounter].speed = 10
 depthcounter++;
 _root.no+=1
 trace(no)
 }else{
 }
};
Key.addListener(myListener);

```

And here is the code us for the bullet MC:

```auto
onClipEvent(enterFrame){
 if(this._x>554){
  _root.no-=1
  this.removeMovieClip();
 }
this._x+=speed
}

```

If I press control before the bullet reaches the end the bullet is removed. Any ideas?

---

<div class="post-metadata">

**Author:** ![abstroose](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@abstroose](https://forum.kirupa.com/u/abstroose)\
**Post date:** [April 16, 2006, 10:07am UTC](https://forum.kirupa.com/t/shooting/185764/2 "2006-04-16T10:07:11Z")

</div>

No worried, I fixed it.
