Creating the score in hidden object game

So we’re creating a hidden object game using Unity. We already created a script for score and for the hidden object to be destroyed whenever clicked.

sc_click.js

function Update () {

	if(Input.GetMouseButtonDown(0))

	{

		var hit: RaycastHit;

		var ray: Ray=Camera.main.ScreenPointToRay (Input.mousePosition);

		

		if(Physics.Raycast(ray, hit))

		{

			if(hit.transform.gameObject == this.gameObject)

			{

				Destroy(this.gameObject);

			}

		}

	}



}

We just created timer on score.js… Can you help us? How to add score (+5) once you destroy an object?

Use GetComponent to get the score variable, and then do:

score += 5;