# Problem with math.random()

**URL:** <https://forum.kirupa.com/t/problem-with-math-random/316090>\
**Category:** Uncategorized\
**Created:** [November 12, 2010, 3:38am UTC](https://forum.kirupa.com/t/problem-with-math-random/316090 "2010-11-12T03:38:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![scorp200](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@scorp200](https://forum.kirupa.com/u/scorp200)\
**Post date:** [November 12, 2010, 3:38am UTC](https://forum.kirupa.com/t/problem-with-math-random/316090/1 "2010-11-12T03:38:25Z")

</div>

hey, im new here  
and i have a problem with Math.random()  
here is part of the code:

```php
//FIRST PLATFORM
				if (P1.vy > 0 && d1 <= 0)
				{
					var Plt1:Platform = new Platform(stage);
					Plt1.addEventListener(Event.REMOVED_FROM_STAGE,remove,false,0,true);
					PFlist.push(Plt1);
					stage.addChild(Plt1);
					Plt1.x = Math.random() * (stage.stageWidth - Plt1.width);
					d1 = Math.floor(Math.random() * rndm + rndm2);
					trace (d1);
				}
				//SECOND PLATFORM
				if (P1.vy > 0 && d2 <= 0)
				{
					var Plt2:Platform2 = new Platform2(stage);
					Plt2.addEventListener(Event.REMOVED_FROM_STAGE,remove,false,0,true);
					PF2list.push(Plt2);
					stage.addChild(Plt2);
					Plt2.x = Math.random() * (stage.stageWidth - Plt2.width);
					d2 = Math.floor(Math.random() * rndm + rndm2);
				}
				//RANDOM d
				d1--;
				d2--;

```

as you can see i have Math.random twice, and 99% of the time they return the same value…
