From first scene to next scene on Spaceshooter 3D carrying scores over using c#

I need a simple C# for space shooter 3D that will transfer me from my first level to the next, that will also maintain the score I reached while changing everything else like back ground. I am so new in scripting that I don’t understand how the DontDestroyOnLod works, thanks fro the replies and explanations.

If you have a score with an int variable you can just make it static. If a variable is static then it will belong to the class that is holding it and will only change it if you change it manually through the class. Normal variables will only hold its value through the instance of the current scene its modified.

public static int Score = 0;

When you change scenes the score will keep the same value and if you want to reset this value you will need to do it manually through the class again by changing the value back to 0.