How do you change UI Text to an int?

I am trying to make a statistic menu in my game which will show you stats about your progress in the game. I am trying to make a text that will tell you how much time you have played the game.

#pragma strict
import UnityEngine.UI;

	static var gamesPlayed : int;
	var gamesPlayedText : UI.Text;
		
function Start () {
	
	gamesPlayed = gamesPlayedText.ToInt();
	gamesPlayedText = GetComponent(UI.Text);
	gamesPlayedText.text = PlayerPrefs.GetInt("gamesPlayedText",0).ToString();
}

function Update () 
{
		

			
			PlayerPrefs.SetInt ("gamesPlayedText", gamesPlayed);
			gamesPlayedText.text = gamesPlayed.ToString();		
}

The problem with this script is that I want it to set the gamesPlayed variable to the gamesPlayedText variable so it won’t go back to 0 whenever I leave the game and go back in. I know that there is a ToString() but when I try ToInt() it gives me an error that it doesn’t exist. So Is there a way to make a UI Text an integer?
Please answer and Thanks in advance.

In C# it would be

int.Parse(gamesPlayedText.text);

Here’s an answer provided to the last person who asked this question as pertains to UnityScript.

I don’t know why you are punishing yourself with UnityScript.

gamesPlayed = Integer.parseInt(gamesPlayedText.text);

Use int.parseInt(gamesPlayedText.text):

intvariable = int.Parse(txtvariable.text);

Replace "intvariable " and “txtvariable”

thx alot!