Is there a way to detect distance between the instances of the same object, “randomStar”, and if it is less than 30px to add some small amount to X and Y so that the stars can be a bit more spaced out?
I would use 2 objects.
A starcreator object and your stars.
Then you create star at starcreator position.
Then you move the starcreator object.
Then you can use starcreator distance to star.
You can use a while loop to create your object, and compare distance with closest object, and if too close, delete it and create another until the distance is acceptable.