How to find and remove the last child of parent?

Hi so I have a game going where I shoot ammo into the air, and then freeze it by pressing on a Key. And I want to only freeze the latest or most recent shot, and not the previous ones. Right now, the problem is that if I shoot lets say 10 times and then press the Key to freeze, it freezes the 1st shot, then the 2nd, then the 3rd, and so on, until it gets to 10.
.

Right now this Freeze method I have gets called when I hit the Key. The “ammoFolder” is a created empty gameobject in the Hierarchy to hold all the instantiated versions of ammo. When I hit the Key, it destroys those clones and creates a new ammo (newStaticAmmo). The main problem seems to be coming from the 1st line. Any ideas? Thanks!

.

void Freeze ()
{
	Transform lastAmmoClone = ammoFolder.transform.GetChild (transform.childCount - 2);

    if (ammoFolder) 
	{ 
		Destroy (lastAmmoClone.gameObject); 

		Rigidbody newStaticAmmo = Instantiate (staticAmmo [Random.Range (0, ammo.Length)], 
        lastAmmoClone.position, lastAmmoClone.rotation) as Rigidbody;

		newStaticAmmo.transform.parent = staticAmmoFolder.transform;
	}
}

If you are using getkey or axis… one that isnt key up, they will be calling the Freeze every frame you hit the key, so make a bool called pressed and a getkeyUp that set that press to false (when you use the getkey, put that bool to true and have a condition that have to be false to enter).

  if(Input.getkey(keycode.A) && !pressed){
      Freeze();
      pressed=true;
  }
  if(input.getkeyUp(keycode.A)){
      pressed=false;
  }

In freeze you should use
Transform lastAmmoClone = ammoFolder.transform.GetChild (ammoFolder.transform.childCount - 1);