Accessing colliders, in if statement

Just to be clear i am using Javascript.
I have been working on trying to detect if my mouse has clicked on a specific collider if it is clicked on that specific collider.

heres my code:

var A1L1 : GameObject;

function Update () {
	if (Input.GetMouseButtonDown (0)) {
		var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
		var hit:RaycastHit;
		if (Physics.Raycast (ray, hit)) {
			Debug.Log("HIT SOMETHING!");
			     if (hit.collider == A1L1) { 
				   Debug.Log("only detected level 1 hit!");


My problem is in the “IF statement” that deals with hitting the specific collider, it is not currently accessing the collider on that game object called A1L1, and is NOT returning Debug.Log(“only detected level 1 hit!”); in my console!

Thanks for the help

As a sidestep to your question, it seems you are trying to allow the player to click an object. You can put a script on the object and use the OnMouseDown() function to detect the click:

    function OnMouseDown () {
		//do something

source: Unity - Scripting API: MonoBehaviour.OnMouseDown()

Needs to be

if(hit.collider.gameObject == A1L1)
    Debug.Log("Your message here");

This is because you defined A1L1 as a GameObject. If you want to just ask if(hit.collider == A1L1), you need to define A1L1 : Collider;