Scripting Trigger and Prefab question.

When using this script and attatching it to a box collider(trigger) that is located at the end of a tile(prefab)(floor piece) it is supposed to destroy the tile and generate a new tile so the ball can continue rolling forward. It runs once then I get a missingreferenceexception error. I am following the book exactly. I was wondering if I’m doing something wrong or if the book is outdated. The book is “Unity 2017 mobile game development”

using UnityEngine;

///


/// Handles spawning a new tile and destroying this one
/// upon the player reaching the end
///

public class TileManager : MonoBehaviour
{
[Tooltip("How much time to wait before destroying " +
“the tile after reaching the end”)]
public float destroyTime = .2f;
void OnTriggerEnter(Collider col)
{
// First check if we collided with the player
if (col.gameObject.GetComponent())
{
// If we did, spawn a new tile
GameObject.FindObjectOfType().SpawnNextTile();

// And destroy this entire tile after a short delay
Destroy(transform.parent.gameObject, destroyTime);
}
}
}

Which line throws the error? Also, you’re destroying the parent of this object and not the object this script is attached to, is that intended?

It doesn’t specify which line causes the error… How would I destroy the object and not the parent? I’m a newbie and following a book to the T and this happend… I think its intended… The idea is to destroy one object(prefab) and create a new one… Its a floor so it should be an endless runner type game