Display variables in GUIText?


I’ve been looking for a solution, but I can’t find one anywhere. I’m using a script which will, when an object collides with the user, give the player 2 points. The script is:

var PlayerScore : int;
var ScoreText = "Points: 0";

function OnTriggerEnter (other : Collider){
	if(other.tag == "point"){
		PlayerScore +=2;
		ScoreText = "Points: " + PlayerScore;

The script works fine, with the player being given 2 points (displayed in the Inspector) upon collision. I was wondering, however, how I can replicate the variable ‘ScoreText’ onto a GUIText which would be displayed in the top corner? I tried re-naming the ‘ScoreText’ to being a public variable, with the code

OnguiText.text == 'ScoreText';

Being connected to the GUIText, but it didn’t seem to work. I’m still learning JavaScript, so all of this is quite new territory to me. If anyone could help, it would be amazing. Thanks much.

add this:

function OnGui(){
    GUILayout.Label(Rect (5,5,10,100), "Points : " +PlayerScore);

Also you do not need ScoreText in the script at all