Selection by material

Hi i look for selection by matérial

i writhe that’s with help i found on web

and is result

NullReferenceException: Object reference not set to an instance of an object
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[ ] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[ ] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.SetProperty (System.Object target, System.String name, System.Object value)
whomat.WhoUseThatMaterial () (at Assets/whomat.js:19)

someone can help plz

when i name it selection.name= “soek”;
is look clear

it’s work’s at morning and now not anymore !!

//#pragma strict


@MenuItem ("Custom/WhoUseThatMaterial #g")



static function WhoUseThatMaterial () {


    var countElem : int = 1;

var materialNameWithoutSpace : String;
var arry:GameObject[];

    var selection : GameObject = Selection.activeObject;
    //selection.name= "soek";
 
 arry.Add = selection;
    
//var select2 :GameObject[];
var count : int=0;
            var materialName1 : String = selection.renderer.sharedMaterial.name.ToString();

//arry.push (selection);

   var gos : GameObject[] = FindObjectsOfType(GameObject);


   for(var go : GameObject in gos){

       if(go.GetComponent(Renderer)){


            var materialName : String = go.renderer.sharedMaterial.name.ToString();



            var space : int = materialName.IndexOf(" ");


            if(space >= 0){

            materialNameWithoutSpace  = materialName.Remove(space);  
            }


            if (materialName ==materialName1  )
            {
            Debug.Log ("+"+go.renderer.sharedMaterials.Length);
        
            if (go.renderer.sharedMaterials.Length == 1){
            Debug.Log (materialName+"+"+materialName1);
          //  go.name = "ok";
          //  selection.name = "ok";
     	 
     	 			count+=1;	
     	 			arry.Add = go;
				// arry[arry.length] = go;

     	 			//arry.push (go);
           }
            }
            
     
 
/*

            if(selection.name == materialNameWithoutSpace){


                print("MAT:    " + selection.name + "       GO:     " + go.name + "      |  " + countElem);


                countElem++;

            }        
*/
        }

    } //if(countElem==1) print("Material " + selection.name + " not used!");


   for(var go : GameObject in gos){

       if(go.GetComponent(Renderer)){
       
       
       
       
       }
       
    }
    
  Selection.objects = arry;
  if (count > 1 )
  {
  
  var yourName :GameObject= new GameObject();
  yourName.name = materialName1;
  	var i : int;		
	while(i<arry.length){
			
			
		arry[i].transform.parent = yourName.transform; 	
	
	i++;
			
 	}
  
  }
}

Thanks for sharing but couldent you just edit your old post

At line number 19:
arry.Add = selection;

the add method is a function, so it uses parenthesis:
arry.Add(selection);