[QUOTE=joxer] tulamide: i tried also make it this way, it works, but it does not work well, sometimes if i click on button, nothing happens[/QUOTE]
You are absolutely right. The reason for this is a mistake I made. By comparing sprite('selector') with random(5), every single instance is compared to that function, so a new random number is generated per instance, which contradicts the original purpose.
The right code would involve another variable, e.g. a global var "myRandom"
+ Button: On Button clicked
-> System: Set global variable 'myRandom' to random(5)
++ Item: "selector" equal to random(5)
--> Item: Spawn object ...
where ++ Item:... is a subevent to + Button: