Referencing other scripts: -5 seconds rule on timer

Hello Unity Users,
I need help with my game timer. In my game, when the ball hits the finishline trigger, what is suppose to happen is:

  • The ball is destroyed
  • minus 5 seconds from the Count-Up timer

I dont know why its giving me problems. I am referring The timer from my working timer script into my finishline script. I keep getting this error.

Assets/Scripts/Finishline.cs(30,32): error CS0120: An object reference is required to access non-static member `Clock2.OnGUI()’

Please Help! Novice Unity User

public class Finishline : MonoBehaviour 
//declare scoring variables
	public int count;
	public GUIText countText;
	//Script Reference
	public int Clock2.OnGUI.Dseconds;
	public Clock2 Timer;

	void Start () 
		count = 0;

//if the balls collides with a finishline collider, finishline destroys the balls and add a point to score.
	void OnTriggerEnter2D(Collider2D other)
		if (other.gameObject.tag == "Ball") 
			Debug.Log ("Object Entered the trigger");
			count += 1;

			// subtract 5 seconds whenever a ball enters the finishline
			Clock2.OnGUI().Dseconds = -5;
			SetCountText ();
			Destroy (other.gameObject);
		if (count > 12) 
				Time.timeScale = 0;

	void SetCountText()
		countText.text = "Number of Balls Collected: "+ count.ToString();
		//	{
		//	winText.text = "You Win!";
		//	}

Clock2.OnGUI().Dseconds = -5;

Here something is wrong. You cannot (or at least should not) use a method with a name already used by Unity.

I don’t quite get what you are after since you want to call the method and then a sub variable which cannot be done in this case.

OnGUI is already taken care by Unity engine so you are not supposed to call yourself, you might as well create a new method with new naming.

Finally I think you are after a common case which is accessing variables from other scripts. You could read the link below I think you will find what you are after.