new percent = 10; // 10 percent chance if( random(100) <= percent ) { // random number beat the 10% chance } else { // 10% chance failed. }