Save whats in GUI.Text field to variable

Hi,
I need to save what the player enters to the text field, and then write that to a file so I’m able to store the playername and score to the file and then sort them, so I’m able to read from the file and display the name with the score on a different scene.

Ideally the player would press a button “Save score” and then the playername would be written to the variable.

I’m trying to make a leaderboard but I’m finding it quite difficult right now.

@hexagonius I think this might be it? But im getting an error (in orange) "Possible mistaken empty statement on line “if (GUI.Button (…” aka savescore button

	void OnGUI ()
	{
		if (PlayerMovement.livess <= 0) 
		{
			GUI.Button (new Rect (400, 200, 300, 200), "Score:" + (count+10));
			PlayerName = GUI.TextField (new Rect (400, 400, 300, 100), PlayerName);
			CountToString ();
			if (GUI.Button (new Rect (400, 500, 200, 100), "Save Score"));
			{
				PlayerNameFinal = PlayerName;
				PlayerAndScore [0] = PlayerNameFinal;
				PlayerAndScore [1] = count1;
				Debug.LogError (PlayerAndScore);
				System.IO.File.WriteAllLines(@"leaderboard.txt", PlayerAndScore);