How to reset a variable?

Hello all,
I want to reset my variable int back to “8” after my SphereKILL is instantiated but I cant figure out how. Here’s my script:

public GameObject SphereKILL;
	public int Counter = 8;
	public int FullCounter;
	public float timer = 30f;

	void Update ()
	{
		timer -= Time.deltaTime;

		{

			if (timer <= 0f)
			if (Counter >= 0)
	Instantiate (SphereKILL, transform.position, transform.rotation);
			
			
				if (timer <= -1f)
					timer = 30f;
			
				if (Counter <= -1)
					Time.timeScale = 0;
			}
		}

	public void CountDoody(int howmany)
	{
		Counter -= howmany;
	}

	}

You’ll need a value to compare against. You could create another, private reference to the SphereKill object.

private GameObject lastSphereKill;

Inside update, compare your current SphereKill reference with this private one.

if(SphereKill !=lastSphereKill)
{
   Counter = 8;
   lastSphereKill=SphereKill;
}

Note, this will reset Counter to 8 even if you just delete the reference to SphereKill, setting it to null. Some additional If’s could guard against that, if necessary.
Edit: Also note, you could do the same thing with an “accessor” to the SphereKill, eliminating the need to store another reference. Alas, accessor’s don’t play well with Unity’s inspector UI and serialization.