Dont Destroy on Load is Destroying!

I am very confused. I just have the simple script:

function Awake () {
    DontDestroyOnLoad (transform.gameObject);
}

attached to my gameObject, but the object still gets destroyed on the next level! What is going on?

Possibly just try:

function Awake(){
  DontDestroyOnLoad(gameObject);
}

Going through the transform to get the gameObject might be causing strange behavior. I know this is how it’s done in the example but I’ve always done it this way and it works fine.

Also, be sure that no other scripts are accidentally destroying the object or it is destroying itself. Seems obvious but sometimes things like this get overlooked.

Also you can use DontDestroyOnLoad(this);