Need Help Destroying clones

I have tried several different things and have failed at all of them. I have also looked around these forums, unity script reference, and unity answers with no luck. I am trying to destroy clones after a set amount of time.

This is what I tried last:

public var dodgeBall: Rigidbody;
public var ballSpeed: float = 25.0;

function Update () 
{

	if(Input.GetButtonDown("Fire1"))
{
	var newBall : Rigidbody = Instantiate(dodgeBall, transform.position, transform.rotation);
	newBall.velocity = transform.TransformDirection(Vector3(0, 0, ballSpeed));
	Physics.IgnoreCollision(newBall.collider, transform.root.collider);
	newBall.timeoutDestructor = 5;
}
	
}

The following is from the scripting reference:

// Kills the game object in 5 seconds after loading the object
Destroy (gameObject, 5);

Attach this to your ball prefab and set whatever time you want before it’s destroyed. All instances of the prefab will then have the script attached and be destroyed at the given time. Hope this is what you’re looking for.

Thank you. I tried Destroy (gameObject, #) but i was adding it to the wrong script. Sometimes, it is just that simple. I need to remember this lol.

We’ve all been there. It’s the small things that get you.:smile: