GUI Grid click

I have a script witch is

var selGridInt : int = 0;
var selStrings : String = [“Empty”, “Empty”, “Empty”, “Empty”];

function OnGUI () {

 if (Input.GetKey("tab"))
  
    selGridInt = GUI.SelectionGrid (Rect (1000, 10, 300, 100), selGridInt, selStrings, 2);

}

and I want it to be able to enable mesh renderer on a sword called “Broadsword” when i click one of them. Any help would be greatly appreciated. Thanks.

void OnGUI()
{
int valueYouWant;

     int storeIndex;

     selGridInt = GUI.SelectionGrid (Rect (1000, 10, 300, 100), selGridInt, selStrings, 2);

     if(storeIndex != selGridInt)
     {
           storeIndex = selGridInt;
           if(selGridInt == valueYouWant)
           {
                //DoWhatYouWant
           }
     }
}

If your selGrindInt has changed check to see if it is the item you want and perform something

Edit: The complete working copy

using UnityEngine;
using System.Collections;

public class DrawGrid : MonoBehaviour {

 public int selGridInt = -1; // The indexer of the grid
 public string[] selStrings; // Itens of the grid
 private int storeIndex = -1; // Store the actual value to check if there was some change in the grid
 public int valueYouWant; // The value you are aiming for, if the grid index match this something must happen!
 
 void Start()
 {
 selGridInt = -1; // Start the grid with nothing selected
 }
 
 void OnGUI()
    {
 selGridInt = GUILayout.SelectionGrid(selGridInt, selStrings, 2); // The grid using GUYLayout so you dont have to define a Rect, if you want to use Rect just use GUI.SelectionGrid

     if(storeIndex != selGridInt) // If the grid index and the value we were holding are diferent it means there was some change in the grid
     {
           storeIndex = selGridInt; // The store now receives the grid index, so the next time OnGUI is called the if statement just above will no be true and this line will no be executed, this way the code is executed only once
           if(selGridInt == valueYouWant) // If the grid index is the value you want do something
           {
                Debug.Log("lol");
           }
     }
 
     }
}

Just keep in mind that the SelectableGrid does not behave like a button. If you are looking for a button like behavior just use button. If you think drawing lots of buttons seems hard and boring try to use GUILayout or even a for/foreach routine to draw them for you.