Need Ammo Box To Respawn

Hello, I’m trying to get an ammo box to respawn after it disappears when I collide with it. Currently, the ammo box is designed so that when I collide with it, my ammo refills, and the ammo box destroys and disappears.
What I want is an ammo box that can respawn 10 seconds later after it disappears, im aware that this might have to be a “deactivate and reactivate” thing instead of being a “destroy and respawn” thing, and thats no problem. I’ve also heard of a possible method where when I collide with the ammo box, the ammo box will just instantly move outside of the map, then 10 seconds later, i can move it back to its original position.

Can anyone please help me out with scripting this, I’ve never seen script that does that and the help would be GREATLY appreciated.

#pragma strict
var shootObject : GameObject;
function Start () {
shootObject = GameObject.FindWithTag("missileLauncher");
}

function Update () {

}

function OnTriggerEnter(other: Collider)
{
	{
	if(other.tag == "homingammopickup")
	{
		shootObject.GetComponent(missilelauncher).ammoCount =2;
		Destroy(other.gameObject);
	}
}
}

you could try this:

var shootObject : GameObject;
var timeToWait : float;

function Start () {
	shootObject = GameObject.FindWithTag("missileLauncher");
}
 
function Update () {
 
}
 
function OnTriggerEnter(other: Collider){
    if(other.tag == "homingammopickup")
    {
       shootObject.GetComponent(missilelauncher).ammoCount =2;
       other.gameObject.SetActive(false);
       yield WaitForSeconds(timeToWait);
       other.gameObject.SetActive(true);
    }
}

What i would do is have an object with only the actual collider, and have the graphics object (your ammo box mesh) as a parent of that. So when you pass over it, it fills your ammo, but then makes the child with the mesh invisible and starts a countdown from what ever time you set it.
Once it’s down to 0, re enable the graphics element and collider for extra pickup.

You can use OnCollisionEmter instead

function OnCollisionEnte(Collision c)
{
shootObject.GetComponent(missilelauncher).ammoCount =2; //NOTE
StartCoroutine("WaitBeforeRespawn");
}

function WaitBeforeRespawn()
{
gameObject.SetActive(false);
yield WaitForSecond(10);
gameObject.SetActive(false);
}

Note: If you want to add 2 mussiles you can use += instead of =, so for example if player somehow gets more than 2 missiles then it removes some of his missiles instead of resupplying him