score resets not sure why

hi ive been looking at my script for too long now that i cant see any problems with it but my score keeps resetting when it reloads the level can you guys have a look and see where i have gone wrong

using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using System.Collections;
//You must include these namespaces
//to use BinaryFormatter
using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;


public class GameLogics : MonoBehaviour {
	public GameObject Tank1;
	public GameObject Tank2;
	public GameObject Tank3;
	public int Tank1Score;
	public int Tank2Score;
	public int Tank3Score;
	public GUISkin CustomSkin;
	float native_width = 800;
	float native_height = 600;

	void Start()
	{
		Tank1Score = PlayerPrefs.GetInt("Blues Score");
		Tank2Score = PlayerPrefs.GetInt("Greens Score");
		Tank3Score = PlayerPrefs.GetInt("Reds Score");

		Debug.Log (Application.dataPath);
			//If not blank then load it
		if(File.Exists(Application.dataPath + "/highscores.txt"))
			{
				//Binary formatter for loading back
				var b = new BinaryFormatter();
				//Get the file
			var f = File.Open(Application.dataPath + "/highscores.txt", FileMode.Open);
				//Load back the scores
				Tank1Score = (int)b.Deserialize(f);
				Tank2Score = (int)b.Deserialize(f);
				Tank3Score = (int)b.Deserialize(f);
			f.Close();
				
			}
		

		Invoke("CountTanks", 2);
	}
	
	void CountTanks()
	{
		Tank1 = GameObject.Find ("Tank1(Clone)");
		Tank2 = GameObject.Find ("Tank2(Clone)");
		Tank3 = GameObject.Find ("Tank3(Clone)");
	}




	// Update is called once per frame
	void Update () 
	{
		if (Input.GetKey(KeyCode.Backspace))
		{
			Application.LoadLevel(1);
		}





		if (Tank1.active == true && Tank2.active == false && Tank3.active == false)
		{

			Tank1Score = Tank1Score + 1;
			PlayerPrefs.SetInt("Blues Score", Tank1Score);
			Application.LoadLevel(1);
		}

		if (Tank2.active == true && Tank1.active == false && Tank3.active == false)
		{

			Tank2Score = Tank2Score + 1;
			PlayerPrefs.SetInt("Greens Score", Tank2Score);
			Application.LoadLevel(1);
		}

		if (Tank3.active == true && Tank2.active == false && Tank1.active == false)
		{

			Tank3Score = Tank3Score + 1;
			PlayerPrefs.SetInt("Reds Score", Tank3Score);
			Application.LoadLevel(1);
		}
		if (Tank3.active == false && Tank2.active == false && Tank1.active == false)
		{
			Application.LoadLevel(1);
		}
	}
	void OnGUI() {
		 GUI.skin = CustomSkin;
		 float rx = Screen.width / native_width;
		 float ry = Screen.height / native_height;
		 GUI.matrix = Matrix4x4.TRS (new Vector3(0f, 0f, 0f), Quaternion.identity, new Vector3(rx, ry, 1f));
        	
		GUILayout.BeginArea (new Rect (250,30,400,30));
		
		GUILayout.BeginHorizontal();

		GUILayout.Button("Blue: "+Tank1Score.ToString());
		GUILayout.Button("Green: "+Tank2Score.ToString());
		GUILayout.Button("Red: "+Tank3Score.ToString());
		GUILayout.EndHorizontal ();
		GUILayout.EndArea ();

		GUILayout.BeginArea (new Rect (250,60,400,30));
		
		GUILayout.BeginHorizontal();
		if (GUILayout.Button("Reset Score"))
		
			Debug.Log("ScoresReset");
			PlayerPrefs.SetInt("Greens Score", 0);
			PlayerPrefs.SetInt("Blues Score", 0);
			PlayerPrefs.SetInt("Reds Score", 0);
		
		if (GUILayout.Button("Save Score"))
		{
			SaveTimes();
		}
		if (GUILayout.Button("Load Score"))
		{
			
		}
		GUILayout.EndHorizontal ();
		GUILayout.EndArea ();
		}

	void SaveTimes()
	{
			Debug.Log("Score Saved");
			//Get a binary formatter
			var b = new BinaryFormatter();
			//Create a file
		var f = File.Create(Application.dataPath + "/highscores.txt");
			//Save the scores
			b.Serialize(f, Tank1Score);
			b.Serialize(f, Tank2Score);
			b.Serialize(f, Tank3Score);
			f.Close();

		System.IO.File.WriteAllText("E:/score.txt", "Tank1Score:" +Tank1Score
		                            +"  "+"Tank2Score:"+Tank2Score
		                            +"  "+"Tank3Score:"+Tank3Score );
	}


}

You are missing curly brackets in OnGUI() after if (GUILayout.Button("Reset Score")) so the if applies only for the Debug.Log call. The scores in prefs are being continuously reset.

What I believe that is going around here is … “CountTanks” is called after 2 seconds as above, meanwhile the update blocks starts executing and hence the control enters the line 95. that is the code block where all the Tanks are inactive and hence reloads the scene.
Add appropriate code check at the beginning of the update block to wait until all three Tanks reference is received or until “CountTanks” is called.

I am not sure if this is the issue, but I tend to use my deserialize otherwise. Try this:

    function Load() {
        if(File.Exists(Application.dataPath + "/highscores.txt")) {
    	    	//Binary formatter for loading back
    	    	BinaryFormatter b = new BinaryFormatter();
    	    	//Get the file
    	    	FileStream f = File.Open(Application.dataPath + "/highscores.txt", FileMode.Open); //I am not sure what File.Open's type is.
    	    	//Load back the scores
    	    	SaveData data = b.Deserialize(f) as SaveData;
    	    	//Close stream, we don't need it anymore.
    	    	f.Close(); 
    	    	//Assign data
    	    	Tank1Score = data.TankScore1;
    	    	Tank2Score = data.TankScore2;
    	    	Tank3Score = data.TankScore3;    
	    }
    }
    
    function Save() {
    	FileStream stream = File.Create(Application.dataPath + "/highscores.txt");
    	BinaryFormatter bf = new BinaryFormatter();
    	
    	SaveData SD = new SaveData();
    	SD.TankScore1 = TankScore1;
    	SD.TankScore2 = TankScore2;
    	SD.TankScore3 = TankScore3;
    	bf.Serialize(stream, SD);
    	stream.Close();
    }
    
    class SaveData {
    	int TankScore1;
    	int TankScore2;
    	int TankScore3;
    	//Add more if needed.
    }