PickUp Weapon in Brick Breaker Game

Hi i created brick brekaer game and weapon it work great. But i dont want to player have always a weapon, i want to create a script so when player destroy every 20 brick, from top will be spawned pickup weapon object. I’m not asking you to make me all of that , just to help me to crate script that will Instantiate weapon object and stick it to player when player pickup weapon object! Tnx in advance!

okay, a solution that can be translated into working code.
First, counting bricks. You need to have a variable to store how many bricks hit so far.
Secondly, you need to check if you have reached that limit.

Lets call it:

int brickHits = 0; // default is 0

Every hit will +1 to this variable.

so you need a function like:

void BrickHit()
{
   brickHits++; // ++ is short for +1 

}

After adding +1 then check if brickHits is above your wanted limit (20)

void BrickHit()
{
   brickHits++; // ++ is short for +1 
   if(brickHits>20)
   { 

       // okay above 20, lets do something, 
       // also remember to re-init the variable for the next weapon drop.
      
       // here you could spawn your weapon drop, play a sound or whatever.
   }


}