GuiText Score On Mouse Click

Hello, Im trying to make a scoring system in two parts, one that is attached to a GUIText and another that is attached to an object to be clicked in order to add up points.

This is what I currently have on the GUIText

var Counter : int = 0;

function onGUI(){
	guiText.text = "Score: "+CountingCode.score;
}

and this is what is on the object to be clicked to get points

CountingCode.js

static var Counter : int = 0;

function OnMouseDown(){
      Counter+=10;
}

When I click the afformentioned object with these scripts active nothing happens. Can someone please show me what is wrong?

Put a Debug statement in OnMouseDown() - I’d guess that it isn’t getting called at all.

Make sure that the object you are clicking on:

  1. has the script CountingCode.js attached to it (which I presume is the case based on your comment)
  2. is a GUI Element or has an active collider attached to it.

Hope it helps!