How do i change script in one scene without changing it in all the scenes

i have 2 scenes
in scene one i want to show a short dialogue and when there are no more scentences left i want it to load the next scene.
but in scene 2 if there are no more sentences left i dont want it to load a new scene but just continue with the game.
so how do i write the script so that it works different in both scenes?? becouse they will have the same names for classes and stuff.

The best way to do this would be to have 2 seperate scripts.

If you really want to use one script, you can use SceneManager.GetActiveScene() to find which scene is active and have 2 functions for the dialogue. For example

print("line1")
    print("line2")
    
    if(SceneManager.GetActiveScene == 1):
       LoadScene()
    else if(SceneManager.GetActiveScene == 2):
      ContinueScene()