How to pass player score to another level

in my game i have a player and all the scores and lives are calculated on the other script called “game manager” which is attached to the prefab “game manager”. My problem is when the player cross the first level all the scores and lives reset to original position. i have tried DontDestroyOnLoad(gameObject). But this doesn’t work.the object doesn’t destroy but the scores get destroyed. can anyone give me a nice way to fix this problem.here is my player code

var horizontalSpeed : float = 2.0;
var verticalSpeed : float = 2.0;
var speed:float=40;
//private var ScoreToShow:GUIText;
//private var LifeToShow:GUIText;
//private var Score:int;
//private var Life:int;
Screen.showCursor = false;
var SendData:GameObject;
//collider.isTrigger = true;

function Update ()
{

transform.Translate(Vector3.forward * Time.deltaTime*speed);

var h : float = horizontalSpeed * Input.GetAxis (“Mouse X”);
var v : float = verticalSpeed * Input.GetAxis (“Mouse Y”);
transform.Translate (h, v, 0);
transform.position.x=Mathf.Clamp(transform.position.x,-8,8);
transform.position.y=Mathf.Clamp(transform.position.y,-9,7);

}
function OnTriggerEnter (other : Collider) {
if(other.tag== “Barrier”){

SendData.transform.GetComponent(“Game Manager”).ReduceLife();
transform.position=Vector3(0,0,-100);

}
if(other.tag== “Bonus”){
SendData.transform.GetComponent(“Game Manager”).AddScore();
Destroy(other.gameObject);

}
if(other.name==“1 complete”){
Application.LoadLevel(“lavel 2”);
}
}

here is my game manager code

private var ScoreToShow:GUIText;
private var LifeToShow:GUIText;
static var Score:int;
static var Life:int=3;

function Awake(){
DontDestroyOnLoad(gameObject);
ScoreToShow = GameObject.Find(“GUI/txt-score”).GetComponent(GUIText);
LifeToShow=GameObject.Find(“GUI/Life text”).GetComponent(GUIText);
UpdateScoreText();
UpdateLifeText();
/var current=Application.loadedLevelName;
if(current==“lavel 1”) {
ScoreToShow = GameObject.Find(“GUI/txt-score”).GetComponent(GUIText);
LifeToShow=GameObject.Find(“GUI/Life text”).GetComponent(GUIText);
Score =0;
Life=3;
UpdateScoreText();
UpdateLifeText();
}
if(current==“lavel 2”){
print(“i am the seccond lavel”);
}
/

}
function Start() {
DontDestroyOnLoad(this);
}
function AddScore(){
Score+=10;
UpdateScoreText();

}
function ReduceLife(){
Life-=1;
UpdateLifeText();

}
function UpdateScoreText(){
ScoreToShow.text = Score.ToString();
}

function UpdateLifeText(){
LifeToShow.text=Life.ToString();
}

please help me fixing this problem

Write the score to a value in PlayerPrefs instead.

yep player prefs would work if you are trying to save it on the hard disk, now another way could be to make a script that will act as a manager and inside on the awake function put: DontDestroyOnLoad(this.gameObject); and this gameobject will be alive all the time until you quit the application.

it’s one of the ways i use to keep data across the levels and let’s say for example in a arcade sence once it’s gameover then you can save the scores rather than having to save it all the time.