How to get an int to equal another int?

I have a building that I can place and when I place it I want it to take a number. I have an int that goes up everytime the building is placed, when the building is placed it takes the total number of that buildings int.

How can I make the HQNumber = the HQNumTotal (An int = an int)?

    if (B.NumberOfTakenButtons == 2) {
    
    
    						if (currentBuilding.CompareTag ("HQ")) {
    
    							B.GetComponent<BuildingsManager> ().HQNumTotal += 1; //Total of this building
    
    							this.gameObject.GetComponent<PlaceableBuilding> ().HQNumber = B.HQNumTotal; //Personal building number of this building
    
    
    
    						}

Not sure if I understand your question completely. But from what it seems you have already solved your own issue. You just have to equal it to the other int as you put in the question.

Example:

int a = 5; 
int b = 0;

void Start()
{
b = a; //b is now equal to a
Debug.Log(b);
}

Try to store it in a temporary integer variable, and then compare it with the HQTotal in Update( ) or OnGUI( ) method, if you want it make it work like a trigger.

something like :

int tempHQnum;

if (B.NumberOfTakenButtons == 2) 
{
         if (currentBuilding.CompareTag ("HQ")) {
     
           B.GetComponent<BuildingsManager> ().HQNumTotal += 1; 
     
           this.gameObject.GetComponent<PlaceableBuilding> ().HQNumber = tempHQnum;

          Debug.Log("HQ num = " + tempHQnum); 
          
         if(tempHQnum == HQNumTotal)
                     DoSomething;
}

This is what I think you can do, If I understand properly what you actually want. If not try using logging every now and then to get what you want.