Bug repeating

Hi, i tried many aproaches and I am stuck in a simple thing. When I collide with an object he spawns in other place and sometimes he just repeats, at the beginning i thought when colliding the object could being spawning in the same place so it would count as collide again and add, but he is doing double points and i dont know why. Ilucidate me please.

colisionObjects: function(player, zona){

   let randomx = Phaser.Math.RND.between(0, this.physics.world.bounds.width);

   let randomy = Phaser.Math.RND.between(0, this.physics.world.bounds.height);

    if(randomx == this.player.x + 50 && randomy == this.player.y + 50 && randomx == this.player.x - 50 && randomy == this.player.y - 50){

       

        console.log('no', zona.x, zona.y);

        this.physics.add.overlap(this.player, this.objects, this.colisionObjects, false, this);

         

    }else{

       

        if(!this.obstaculos.getTileAtWorldXY(zona.x, zona.y) && !this.areia.getTileAtWorldXY(zona.x, zona.y)){

            zona.x = randomx;

            zona.y = randomy;

            this.trashNumber++;

            console.log(this.trashNumber);

        }else{

            console.log('no', zona.x, zona.y);

            this.physics.add.overlap(this.player, this.objects, this.colisionObjects, false, this);

        }

       

    }

    this.cameras.main.shake(10);

    this.cameras.main.flash(10);

},

Remove these from colisionObjects().

My point is repeating the function in case the object spawns in the player or in the layers obstaculos and areia, so if the x and y are the same he repeats the function to find another x and y, if i take it off the objects will start deseapiring eventually right? Even like this e continues adding 2 or 3 instead of 1:

colisionObjects: function(player, zona){

   let randomx = Phaser.Math.RND.between(0, this.physics.world.bounds.width);

   let randomy = Phaser.Math.RND.between(0, this.physics.world.bounds.height);

    if(randomx == this.player.x && randomy == this.player.y){

       

        console.log('no', ramdomx, ramdomy);

        //this.physics.add.overlap(this.player, this.objects, this.colisionObjects, false, this);

         

    }else{

        if(!this.obstaculos.getTileAtWorldXY(zona.x, zona.y) && !this.areia.getTileAtWorldXY(zona.x, zona.y)){

            zona.x = randomx;

            zona.y = randomy;

            this.trashNumber++;

            console.log(this.trashNumber);

        }else{

            console.log('no', ramdomx, ramdomy);

           // this.physics.add.overlap(this.player, this.objects, this.colisionObjects, false, this);

        }

       

    }

    this.cameras.main.shake(10);

    this.cameras.main.flash(10);

},

To do it that way I think you would call instead:

this.colisionObjects(this.player, zona);

It works like this, but he still add more than 1 to the objects, and i have no idea, is like a bug and counts 2 instead of one, i made the console log count for me, so i know he is getting one by one, is like the function repeats it self.

colisionObjects: function(player, zona){

   let randomx = Phaser.Math.RND.between(0, this.physics.world.bounds.width);

   let randomy = Phaser.Math.RND.between(0, this.physics.world.bounds.height);

   if(randomx <= this.player.x + 50 && randomy <= this.player.y + 50 && randomx >= this.player.x - 50 && randomy >= this.player.y - 50){



        console.log('no-player', randomx, randomy);

        this.colisionObjects(this.player, zona);            

         

    }else{

        if(!this.obstaculos.getTileAtWorldXY(randomx, randomy) && !this.areia.getTileAtWorldXY(randomx, randomy)){

            zona.x = randomx;

            zona.y = randomy;

            this.trashNumber++;

            console.log(this.trashNumber);

        }else{

           

            console.log('no', randomx, randomy);

            this.colisionObjects(this.player, zona);

       

        }

       

    }

    this.cameras.main.shake(10);

    this.cameras.main.flash(10);

},

So from begginning, I create an object group with 100 objects each one with a random x and y and random sprites, then if i colide my player with one of this objects I do an overlap of the x and y so the object I have collided spawns in a diferent area calling the function colision objects.
Then to not allowing the object to spawn in no-area or above the player i do:

Create two random x and y, do verification if those are in the player x and y +200(area) if is in that area make the function again to find another x and y. if is not in that area proceed, the same for the layers. I dont understand why he is adding 2 ,3, 4 or 5+, when he only can make the if once.