Weird code, not working :(

Hello guys, I’m currently making a small game to test my newbie skills, but I can’t seem to find a way out of this thing… It’s an error that I’m stuck on. Please if you can help me !

So this is the code that I’m working on -
public class TransformFunctions : MonoBehaviour {

	public float speed;

	private Light myLight;

	private float lRange = 2.5f;
	private float orange = 8f;
	public float rotateSpeed;

	public TextMesh Bateries;
	public int counter;
	public int i;
	void Start()
	{
		myLight = GetComponent<Light> ();
		counter = 0;
		i = 0;
	}

	// Update is called once per frame
	void Update () 
	{
		ColorChange ();
		Movement ();
		ExitApp ();
	}

	void FixedUpdate (){
		SetCountText ();
		Minus ();
		}
	void OnTriggerEnter (Collider other)
	{
		if (other.gameObject.tag == "PickUp") 
		{
			other.gameObject.SetActive(false);
			counter = counter + 1;
		}
	}
	void SetCountText()
	{
		if (Input.GetKeyDown ((KeyCode.A))
		    i = counter - 1;
		
			while(counter > 0){
				counter--;
			}
	}

	void Minus () {


	}

			void Movement(){
				if (Input.GetKey (KeyCode.UpArrow)) {
						transform.Translate (Vector3.forward * speed * Time.deltaTime);
				}
				if (Input.GetKey (KeyCode.DownArrow)) {
						transform.Translate (Vector3.back * speed * Time.deltaTime);
				}
				if (Input.GetKey (KeyCode.LeftArrow)) {
						transform.Rotate (Vector3.down * rotateSpeed * Time.deltaTime);
				}
				if (Input.GetKey (KeyCode.RightArrow)) {
						transform.Rotate (Vector3.up * rotateSpeed * Time.deltaTime);
				}
				if (Input.GetKeyDown (KeyCode.Space)) {
						myLight.enabled = !myLight.enabled;
				}
				if (Input.GetKeyDown (KeyCode.LeftAlt)) {
						myLight.type = LightType.Point;
						myLight.range = lRange;
				} else if (Input.GetKeyDown (KeyCode.LeftShift)) {
						myLight.type = LightType.Spot;
						myLight.range = orange;
				}
		}
	 	void ExitApp(){
				if (Input.GetKey (KeyCode.Escape)) {
						Application.Quit ();
				}
	}
		void ColorChange(){
		if (Input.GetKey (KeyCode.Keypad0)) {
						myLight.light.color = Color.cyan;
				}
		if (Input.GetKey (KeyCode.Keypad1)) {
			myLight.light.color = Color.red;
		}
		if (Input.GetKey (KeyCode.Keypad2)) {
			myLight.light.color = Color.yellow;
		}
		if (Input.GetKey (KeyCode.Keypad3)) {
			myLight.light.color = Color.green;
		}
		if (Input.GetKey (KeyCode.Keypad4)) {
			myLight.light.color = Color.magenta;
		}
		}
}

I want to make something like flashlight in the game but I can’t seem to make the counter stop at 0 when using the picked object. I’m trying to make the player to pick an object which will be baterie of some kind and then the counter increases and you have + 1 baterie. But when you press A I want to use that batterie and make the counter - 1 of the total bateries that I have. It worked untill I noticed that I can press A every time and the GUI Text counter goes -1 then - 2 and so on… What should I do ? And for this code Unity is showing me this WEIRD ERROR -

Assets/Lesson2 13/TransformFunctions.cs(47,21): Error CS1525: Unexpected symbol 'i'

What does it expects? I don’t know… I’m still a newbie to this but I can’t figure it out :frowning: Please help UNITY COMMUNITY!!!

If you cannot spot the error in the current line, check the one above. In this case, you have an extra ‘(’. The line should be:

if (Input.GetKeyDown (KeyCode.A))

It looks like a missing closing bracket at line 41.