Distance between randomly spawned objects

Does that approach resolve your issue? Are you able to to add this kind of logic around here?

if(random(1) < 0.005) {