Attaching scripts to meshes with multiple materials

I am trying to attach a texture offset script to a combined object with multiple textures. How can I attach the script so that each texture can have their own input values for this script?

you can refer to a specific material by using
Renderer.Materials[index]

Materials with an ā€œSā€

Try somthing like this:

private var scrollSpeed : float = 0.05;


function Update () {

		var offset : float = Time.time * scrollSpeed;
		
		//Change material number and name for your own
		if(renderer.materials[0].name == "Water_Mat (Instance)"){
		
			renderer.materials[0].SetTextureOffset ("_MainTex", Vector2(-offset,0));
			renderer.materials[0].SetTextureOffset ("_BumpMap", Vector2(-offset,0));
		}
		}
	}