Create clickable GameObjects (JS)

I have a 2d board of some hundreds of board pieces, and I need to make ALL of them clickable. How would I do it with possibly GUIButtons or some other way to do it?

I have the code for what happens when the buttons are clicked, but I just need a way to make them clickable.

This is in a 2D JS environment.

Thanks in advance!

P.S. I’ve seen similar Q&As about this, however none of the raycasting code works.

P.P.S. My last question was deleted for no reason. PLEASE STOP!

your object need collider and your camera must be set as main

 function Update() {
    if(Input.GetMouseButton(0)){
            var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
            var hit : RaycastHit;
            if (Physics.Raycast (ray, hit,1000)) {
                 if (hit.collider.gameObject.tag=="something") {
                        Debug.Log("Success");
                    }
              }
           }
        }