Is there any way to destroy script at certain level ?

As the title says, is there any way to destroy script at certain level ?

the script that I need to destroy is “DoNotDestroyOnLoad” !!

I attached it to empty gameObject that contains audio source and I want to stop the music if the player reaches level “whatever” !

Please help me, this is so important for me !!!

1 Answer

1

Add this to it

var levelName : String = "levelone"; // change this obviously...
    
function Start(){
  if(Application.loadedLevelName == levelName ){
     Destroy(this);
  }
}

Thank you so much <3