How Pick up Clips for reload ammo?

After more research I have not found the solution, making a response PaxNemesis I thank btw who give a script here on the site reloading of ammo I took the idea for his script only if the player supports several times on the “R” key it gets ammunition at will, and if he picks up ammo and reload it loses all the ammunition that the pick …
What I seek is the ability to pick clips that give ammunition when the player input “R”
For example, I 5Clips 10Munition and I reload and I 4clips and 50Munitions
here is the script to publish PaxNemesis

So how to pick the clips that come in the script to add that when you press the R using the following?

Thank you for your reply but it does not work.
I’ll post my two Script.
Ammo Pickup and a piece of my shooting script with ammos

Script PickUp :

using UnityEngine;
using System.Collections;

public class Ammo : MonoBehaviour {
	
	//script on player
	private GameObject shootObject;
	void Start () {
		shootObject = GameObject.FindWithTag("shooter");
	}
	void OnTriggerEnter(Collider Cube){
	if (Cube.tag == "ammo") {
			shootObject.GetComponent<Input>().ammo += 50;
			Destroy (Cube.gameObject);
				}
	}
}

Small parenthesis, This script works BUT If for example I open a Scene or Unity, software Script does not work
(Error: Object reference not set to instance of year year object)
And so when the script work adds me well Ammo 50 in the weapon the player.

Then the Script :

using UnityEngine;
using System.Collections.Generic;

public class Input: MonoBehaviour

         public int ammo;
    	 public bool reloading = false;

    	 void Start () {
    		ammo = 50;
                           }
    	protected virtual void Update()
    	{
    
    		if (Input.GetKeyDown(KeyCode.R))
    			Reload();
    			UpdateCursorLock ();
    
    
    			if (Player.Pause.Get () == true)
    				return;
    
    
    			if (!m_AllowGameplayInput)
    				return;
    
    
    			InputAttack ();
    
    		
    	}
    protected virtual void UpdateCursorLock()
    	{
    
    
    
    		if (Input.GetAxis ("Fire1") > 0.5f || Input.GetMouseButton (0)) {
    			if (!reloading && ammo > 0) { 
    				ammo --;
    
    				Player.Attack.TryStop ();
    				Fire ();
    			}
    
    			if (ammo <= 0)
    				Reload();
    
    			Screen.lockCursor = false;
    
    			Screen.lockCursor = true;
    		}
    	}
    	void Reload()
    	{
    		reloading = true;
    		ammo = 50;
    		reloading = false;
    	}

So now back to my question and you answer it-is that it will work with your script on my own?

ideally you would have a separate script for the ammo clips like

//call this class something like ammoScript
public int ammoType = 1; //optional can choose what sort of ammo, this would have to be referenced later
public int ammoQty = 10; //quantity of ammo in this 'clip'

then you have a collision script to detect if the player has picked up the ammo and then collect the data from the ammoScript like

//imaginary playerscript

int ammoBullets = 0;
int ammoRockets = 0;
int ammoGrenades = 0;

ammoScript ammoPickup;


void OnCollisionEnter(Collision collision)
{
 if(collision.gameObject.tag == "ammo")
 {
 ammoPickup = collision.gameObject.getComponent<ammoScript>();
 
  switch(ammoPickup.ammoType)
  {
   case 1: //bullets
   {
   ammoBullets += ammoPickup.ammoQty;
   break;
   }
   case 2: //rockets
   {
   ammoRockets += ammoPickup.ammoQty;
   break;
   }
   case 3: //grenades
   {
   ammoGrenades += ammoPickup.ammoQty;
   break;
   }
  }
Destroy(collision.gameObject);

}
}

havent got time to test this right now, but hopefully the principle will be obvious.

I have my reload script, you can try to use it for your needs:

		public IEnumerator Reload()
			{
			status = "reloading";
			yield return new WaitForSeconds(1);
			if(magazines > 0)
				{
				bullets = magazineSize;
				magazines--;
				}
			status = "";
			}

MUST BE RUN USING StartCoroutine(“Reload”);