# AI help

**URL:** https://forum.kirupa.com/t/ai-help/221508
**Category:** Uncategorized
**Created:** [April 4, 2007, 7:50pm UTC](https://forum.kirupa.com/t/ai-help/221508 "2007-04-04T19:50:12Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![smith1302](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@smith1302](https://forum.kirupa.com/u/smith1302)
#### Post date: [April 4, 2007, 7:50pm UTC](https://forum.kirupa.com/t/ai-help/221508/1 "2007-04-04T19:50:12Z")

</div>

i have an AI script that is supposed to run when i click a button but it works only when i click the button and when i let go clicking it the AI script stops. how do i get around this?

heres wut i have

this.onRelease = function () {  
if(\_root.man.\_x \> this.\_x) {  
this.play();  
this.\_x += speed;

} if(\_root.man.\_x \< this.\_x) {  
this.play();  
this.\_x -= speed;

} if(\_root.man.\_y \> this.\_y) {  
this.play();  
this.\_y += speed;

} if(\_root.man.\_y \< this.\_y) {  
this.play();  
this.\_y -= speed;

}  
if (this.hitTest(\_root.man)) {  
speed = 0;  
this.stop();  
}else { if (this.hitTest(\_root.man)== false) {  
speed = 4;  
this.play();  
}  
}

}

i want the script to keep running even after i click the button
