How to reach a variable in another scene?

So, i have ym onDeathMenu in another scene, and i want to put in the score the player reached there, but the ScoreSystem (holding the score variable) is in antoher script. How would i ssolve this? I’ve tried to getcomponent oin the script which did not work. I’ve also tried to make a GameObject variable and put the player (holding scoresystemscript) in, and then getcompoenent on the player GameObject to reach the script, which did not work either since i could not choose the player GameObject (probably cuz it is in another scene.).

You can’t reference an object in another scene, however there are some other paths you can take to:

You can store the scores independently by using the PlayerPrefs object. This will allow you to store variables between scenes and game loads and subsequently pull those values back out when you desire.
A simple search here becomes quite fruitful:
http://unity3d.com/search?refinement=answers&gq=playerprefs

The next idea is to use a static object to retain your game variables that you want to transend scenes. This includes “marking” the variable as DontDestroyOnLoad which will allow the object to exist between scenes, but not between game loads(exiting and starting again).
Once again another search will bring you into the light:

http://unity3d.com/search?refinement=answers&gq=static%20score