# Duplicating mc's removing themselves

**URL:** <https://forum.kirupa.com/t/duplicating-mcs-removing-themselves/309294>\
**Category:** Uncategorized\
**Created:** [May 11, 2010, 5:32pm UTC](https://forum.kirupa.com/t/duplicating-mcs-removing-themselves/309294 "2010-05-11T17:32:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![availableName](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@availableName](https://forum.kirupa.com/u/availableName)\
**Post date:** [May 11, 2010, 5:32pm UTC](https://forum.kirupa.com/t/duplicating-mcs-removing-themselves/309294/1 "2010-05-11T17:32:52Z")

</div>

i created a shooter game, and in this the enemy is supposed to spawn to the right of the stage and move left on the x axis (see attachment). my dilemma is that these duplicated instances are removing themselves. i think this may be related to depth issues…not sure. please help. Here’s the code I have placed on the original movie clip:

onClipEvent (load) {  
var jeepspeed = 7;  
var jeeplife = 300;  
//var totalBullets = \_root.tank\_mc.i;  
var i = 1; // used for jeep instance name and depth  
}  
onClipEvent (enterFrame) {  
var dificulty = .01;  
var rand1 = Math.random();  
var rand = Math.random();  
trace("rand = " + rand);

if (rand \<= dificulty) {  
\_root.jeep\_mc.duplicateMovieClip(“jeep\_mc” + i, i);  
trace(“i = " + i);  
eval(”\_root.jeep\_mc" + i).\_x = 570;  
eval("\_root.jeep\_mc" + i).\_y = rand1 \* 400;  
i++;  
}  
//totalBullets = \_root.tank\_mc.i;  
this.\_x -= jeepspeed;  
for (var j = 0; j \< totalBullets; j++) {  
if (\_root.jeep\_mc.hitTest("\_root.shell\_mc" + j)) {  
jeeplife -= 50;  
//help from kumbar  
}  
}  
if (jeeplife \<= 0) {  
trace(“test”);  
\_root.jeep\_mc.removeMovieClip();  
}  
}
