Score system

I’m programming a simple 2d game for android where you have to kill (destuir) objects that appear on the screen by touching them with your finger, then in my code the score is not working properly because the score increases as had destroyed all the objects in the game, and should be destroyed only assume as one

this is my code

using UnityEngine;

using System.Collections;

public class AddPoints : MonoBehaviour 

{
	
	void Update () 

	{

		if (Input.anyKeyDown)
			
		{
			 PointScore.pointScore += 1f;
		}
		
	}
	void OnMouseDown(){
	
		Destroy (this.gameObject);
	}   
public float lifetime = 1.0f;
	void  Awake ()
	{
		Destroy(this, lifetime);
	}
	
	

	
}





and



using UnityEngine;

using System.Collections;



public class PointScore : MonoBehaviour 
	
{
	
	public static float pointScore = 0;
	
	
	
	void OnGUI () 
		
	{
		
		GUI.Label (new Rect (10, 10, 100, 20), "Score: " + pointScore);
		
	}
	
}

if you can help I would be very grateful

You shouldn’t be using “Input.anyKeyDown” to update your score. That will return true for EVERY object testing it, for EVERY keystroke or click; thus, your score updates by the number of scoreable objects with every click.

Remove that code, and just put your “PointScore.pointScore += 1f;” in the same OnMouseDown function with your Destroy, and you should be fine.