GetComponent doesn't work

Hello,

I make a game where after a set amount of time scene changes.
The new scene should modify a text mesh to present the score of the older scene.
I have this script but it doesn’t work, any help??

var scoreHold : int;

function Awake () {
	DontDestroyOnLoad (transform.gameObject);
	if(GameObject.Find("TextScore"))
	{
		var textandpoints : TextMesh = GameObject.Find("TextScore").GetComponent("TextMesh");
		textandpoints.text = ("Example");
	}
}

It’s because the Awake function only happens once.

The Awake is called when the object is first placed on the scene.

If you use “DontDestroyOnLoad” then the objects stays where it is when changing scenes.

Awake does not happened again on each scene change (same goes for Start).

Awake is executed only once, when the object is created. If you want to do something with TextScore whenever the scene changes, place DontDestroyOnLoad in a TextScore script and put the rest of the code in any other object - the object will be created when the scene starts and execute its Start function:

TextScore script:

var scoreHold : int;

function Awake () {
    DontDestroyOnLoad (transform.gameObject);
}

Script attached to any other object:

function Start(){
    var txtScore = GameObject.Find("TextScore");
    if (txtScore){
       var textandpoints : TextMesh = txtScore.GetComponent(TextMesh);
       textandpoints.text = ("Example");
    }
}