# Help with "target path" problem

**URL:** <https://forum.kirupa.com/t/help-with-target-path-problem/242021>\
**Category:** programming\
**Created:** [October 21, 2007, 6:26am UTC](https://forum.kirupa.com/t/help-with-target-path-problem/242021 "2007-10-21T06:26:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zach93111](https://avatars.discourse-cdn.com/v4/letter/z/e0b2c6/32.png) [@zach93111](https://forum.kirupa.com/u/zach93111)\
**Post date:** [October 21, 2007, 6:26am UTC](https://forum.kirupa.com/t/help-with-target-path-problem/242021/1 "2007-10-21T06:26:40Z")

</div>

So I have this script…

I want to put the following clip [toad] inside a NEW movie clip…

so I tried

TOAD = \_root.castle[“toad”+k]  
^The code failed to work, The character, would just stand there doing nothing…

Whats wrong with, my “target path”?

```php

num = 3;
numA = 8;
distance = 450;
fire = false;
money=250
enemies=5
onEnterFrame = function () {
    for (k=0; k<num; k++) {
        for (k=0; k<numA; k++) {
            TOAD = _root["toad"+k];
            ENEMY = _root["enemy"+k];
            Xmouse = _root.ENEMY._x;
            Ymouse = _root.ENEMY._y;
            gunX = _root.TOAD._x;
            gunY = _root.TOAD._y;
            angle = Math.atan2(Ymouse-gunY, Xmouse-gunX)/(Math.PI/180);
            if (Math.sqrt((Xmouse-gunX)*(Xmouse-gunX)+(Ymouse-gunY)*(Ymouse-gunY))<distance) {
                fire = true;
            }
            if (Math.sqrt((Xmouse-gunX)*(Xmouse-gunX)+(Ymouse-gunY)*(Ymouse-gunY))>distance) {
                fire = false;
            }
            if (fire == true) {
                _root.TOAD.gun._rotation = angle;
                _root.TOAD.gun.gotoAndStop(2);
                _root.TOAD.gun.spray.play();
            }
            if (fire == false) {
                _root.TOAD.gun.gotoAndStop(1);
                _root.TOAD.gun._rotation = 180;
            }
        }
    }
};

```
