How can you use a Coroutine and WaitForSeconds to repeat actions?

Im making an RTS game where there are resource collectors that take resources from other gameobjects… I want there to be a pause when they are taking the resources so they don’t get filled up so fast. I need help with making the unit collect and wait a couple seconds then collect again then repeat until it is filled up.

public IEnumerator Harvest()
            
            
            
if (PlasticCarryAmount < 30) {
        
             this.gameObject.GetComponent<ResourceCollection> ().PlasticCarryAmount += 10;  //Add this to carry amount
            
            yield return new WaitForSeconds (3); //Wait a couple seconds then repeat until PlasticCarryAmount is not less than 30
   			
} else
      {
         Harvesting = false;
       }
 }

Just put a while condition

while (true) {
    if (PlasticCarryAmount < 30) {
             
                  this.gameObject.GetComponent<ResourceCollection> ().PlasticCarryAmount += 10;  //Add this to carry amount
                 
                 yield return new WaitForSeconds (3); //Wait a couple seconds then repeat until PlasticCarryAmount is not less than 30
                    
     } else
           {
              Harvesting = false;
              break;
            }
      }
}

This will repeat till your if condition stays true.