When one thing spawn another will be destroyed

Hey, I'm wondering if it's possible to add a script to an object and when that object spawn's another thing I've assigned to the script will be destroyed.

If so, could someone link me an answered question or example if u know of any cuz I've been searching around and couldn't find anything.

public GameObject spawnObject; // assign the prefab you want to spawn after X time.
public float spawnTime = 50; // time after which spawnObject is spawned

public GameObject[] destroyObjects; // Objects to be destroyed when spawnedObject is spawned.

void Start()
{
    Invoke( "SpawnAndDestroy", spawnTime );
}

void SpawnAndDestroy()
{
    if( spawnObject != null )
        Instantiate( spawnObject );

    if( destroyObjects != null )
    {
        foreach(GameObject destroyObject in destroyObjects)
        {
            Destroy(destroyObject);
        }
    }
}

Untested.