Потому что в итоге код будет таким:
Код:
var a = ["Female Heroes", "Male Heroes"]
var b = [0,1,2,3,4,5,6,7]
var x = Math.floor(Math.random() * (2))
var y = Math.floor(Math.random() * (8))
loop1:
var h = Math.floor(Math.random() * (20))
if  $gameVariables.value(30)[h] <> 0 {$gameSelfSwitches.setValue([this._mapId, $gameVariables.value(30)[h], 'C'], true)
$gameVariables.value(30)[h]=0
this.wait(5)
setTimeout(function() {$gameMap.event(1).setImage(a[x], b[y])}, 40)}
else {continue loop1}