issue with spawn in random numbers of objects

Hello guys, can you help me, please.
I have in scene 5 boxes. And when I hit the box - it spawns a sphere instead of the each box.
But how to spawn sphere from random numbers of boxes (not all)?

Put a collision on it and spawn a Sphere in side another collision box.

maybe I not correct explained,


Now I have spawn a sphere always, inside all of the box.
But how spawn it randomly, not in all?

anybody, any help??

You only want it to spawn the sphere sometimes? As in 50% of boxes hit will spawn a sphere, or something along those lines?

If that’s what you are going for then I would just create a branch and generate a random integer. Do a greater than check and only spawn the if the result is true.

Or if you want multiple items to appear the do a for loop and set the end index to a random number in whatever range you want.

Thank`s man, it helps .