# Script help

**URL:** <https://forum.kirupa.com/t/script-help/190305>\
**Category:** Uncategorized\
**Created:** [June 10, 2006, 8:59am UTC](https://forum.kirupa.com/t/script-help/190305 "2006-06-10T08:59:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mayjarboi](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@mayjarboi](https://forum.kirupa.com/u/mayjarboi)\
**Post date:** [June 10, 2006, 8:59am UTC](https://forum.kirupa.com/t/script-help/190305/1 "2006-06-10T08:59:03Z")

</div>

hello well this code below and it seems be a good script but it doest seem to work. the enemy just stands still, can any one help?

[AS]action = “stand”;  
dir = “r”;  
atone = false;  
attwo = false;  
atthree = false;  
heroat = false;  
///////////////////////////////////////////////////////////  
enemy.onEnterFrame = function() {  
this.gotoAndStop(action+" "+dir);  
xdi = enemy.\_x-hero.\_x;  
ydi = enemy.\_y-hero.\_y;  
di = (xdi+ydi)/2;  
if (distance\>200) {  
if (xdi\>=50 && heroat == false) {  
atstyle = random(3);  
if (atstyle == 1) {  
atone = true;  
action = “atone”;  
dir = “r”;  
} else {  
if (atstyle == 2) {  
attwo = true;  
action = “attwo”;  
dir = “r”;  
} else {  
if (atstyle == 3) {  
atthree = true;  
action = “atthree”;  
dir = “r”;  
}  
}  
}  
}  
}  
};[/AS]

> that is the main code which goes on the first frame
