# DuplicateMovie Problem?

**URL:** <https://forum.kirupa.com/t/duplicatemovie-problem/309993>\
**Category:** flash\
**Created:** [May 29, 2010, 4:59pm UTC](https://forum.kirupa.com/t/duplicatemovie-problem/309993 "2010-05-29T16:59:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewdagrate](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@andrewdagrate](https://forum.kirupa.com/u/andrewdagrate)\
**Post date:** [May 29, 2010, 4:59pm UTC](https://forum.kirupa.com/t/duplicatemovie-problem/309993/1 "2010-05-29T16:59:05Z")

</div>

[Fixed. Changed to attachMovie instead of Duplicate. Sorry for wasting your time]

Hi. I’m having trouble with a code in my game, but I’m not entirely sure whether this thread belongs here. Anyways…

Basically, when the enemy is attached, the \_root.totalenemies goes up by 1. When it goes down, it subtracts by 1. Also when the enemy is loaded, the \_root.enemyinstance goes up by one. The \_root.enemyinstance is added onto the end of the enemy’s movieclip instance name (or it’s supposed to).

Now what the code is supposed to be doing it finding out whether or not there are least than 5, and if there are, load 1 enemy every two seconds. For some reason it only works once.

Below is the code.  
Can anyone help me?

\_root.totalenemies=0  
\_root.enemyinstance=0  
\_root.attachMovie(“greencubeenemy1”, “enemy”, 1, {\_x:50, \_y: 352});  
function wait() {  
if(\_root.totalenemies\<5){  
for (a=\_root.enemyinstance; a\<=1; a++){  
enemy.duplicateMovieClip(“enemy”+a, \_root.getNextHighestDepth())  
}  
}  
}  
myTimer = setInterval(wait, 2000);

Thank you.
