# Hittest random goto and play help

**URL:** <https://forum.kirupa.com/t/hittest-random-goto-and-play-help/317741>\
**Category:** Uncategorized\
**Created:** [December 31, 2010, 10:25pm UTC](https://forum.kirupa.com/t/hittest-random-goto-and-play-help/317741 "2010-12-31T22:25:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![skullface](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@skullface](https://forum.kirupa.com/u/skullface)\
**Post date:** [December 31, 2010, 10:25pm UTC](https://forum.kirupa.com/t/hittest-random-goto-and-play-help/317741/1 "2010-12-31T22:25:24Z")

</div>

Hi everyone my name is Justin Lamoureux and i am new to actionscripting although i do know a little I dont know much… this is my problem I am trying to right a code that will help me make a random gotoAndPlay hits test script like you see the the popular game Pokemon. I have a character that is going over top of another movie clip but i want it to start generating random number and once it its a certain number i want it to go to the frame it is assigned to

this is what i have so far:

onClipEvent (enterFrame){  
if(\_root.guy\_mc.hitTest(this)){  
var randomNumber = Math.floor(Math.random()\*4+1);  
trace(randomNumber);

```
if(_root.random == 1(gotoAndPlay("battel1"))){
    gotoAndPlay("battle1");
}

```

///-- I even wrote it two different ways to see if it would work but it doesnt ---------/////

```
if(_root.randomNumber == 3){
    gotoAndPlay("battle2");

```

}  
}  
}

thanx for everyone who helps out
