Object Dont Destroy On Load - With Exception

I have a script attached to my “TouchControls” gameobject, I don’t want it to destroy on load; so I added the “DontDestroyOnLoad(transform.gameObject);” line. But I want it to destroy when loading certain scenes, for example my Main Menu (“Menu”) and my level select menu (“LevelMenu”).

Here is the script so far…

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class TouchControls : MonoBehaviour {

	public PlayerController Player;

	public Animator AudioAnim;
	public GameObject AudioButton;
	public bool Audio;

	public bool Paused;
	
	void Awake()
	{
		DontDestroyOnLoad(transform.gameObject);
	}

	void Start()
	{
		Player = FindObjectOfType<PlayerController> ();
		AudioAnim = AudioButton.GetComponent<Animator> ();
	}

	public void LeftArrow()
	{
		Player.Move (-1);
	}

	public void RightArrow()
	{
		Player.Move (1);
	}

	public void UnpressedArrow()
	{
		Player.Move (0);
	}

	public void Ball()
	{
		Player.FireBall ();
	}

	public void Jump()
	{
		Player.Jump ();
	}

	public void ExitToMenu()
	{
		StartCoroutine(ExitGame());
	}

	IEnumerator ExitGame()
	{
		float fadeTime = GameObject.Find ("Level Manager").GetComponent<Fading>().BeginFade (1);
		yield return new WaitForSeconds(fadeTime);
		Application.LoadLevel("Menu");
	}

	public void AudioChange()
	{
		Audio = !Audio;

		if (Audio) {
			AudioListener.pause = true;
			AudioAnim.SetBool ("Audio", false);
		}
		if (!Audio) {
			AudioListener.pause = false;
			AudioAnim.SetBool ("Audio", true);
		}
	}

	public void PauseGame()
	{
		Paused = !Paused;

		if (Paused) {
			Time.timeScale = 0F;
		}
		if (!Paused) {
			Time.timeScale = 1F;
		}
	}
}

In the Start() function you can do:

if (Application.loadedLevel == "LevelNameInWhichObjectHasToBeDestroied"){
   Destroy(transform.gameObject);
}

Hope this works for you.