How to change all gameobjects with a certain tag or name onclick

Tried a heap of different ways but can only get it to change one object at a time.

Any help? (Sorry I’m new)

var object : GameObject;

object = GameObject.FindGameObjectsWithTag(“Roof”);

var texture : Texture;

function OnMouseDown(){
object.renderer.material.mainTexture = texture;
}

Since you already had collected all Roof objects in an array, just use a for to iterate through them all and change their materials:

var object : GameObject[];
object = GameObject.FindGameObjectsWithTag("Roof");
var texture : Texture;

function OnMouseDown(){ 
  for (var obj: GameObject in object){
    obj.renderer.material.mainTexture = texture;
  }
}