How to change a game object's texture?

Hello! I am making a 2D game and my background needs to be animated. I want to swap the textures of a plane in accordance to an object's position. I tried several approaches, and I think this is the closest:

var BG01 : Texture;

var g_Background = gameObject.Find("g_Background");

if((gameObject.transform.position.x) >= 1)
renderer.material.SetTexture("g_Background", BG01);

but I get this error: "Material doesn't have a texture property "g_Background" "

So how would I do that? or is there another way to do this?

Thanks a bunch!

Well, I got it now. I used the code on the plane object itself:

renderer.material.mainTexture = BG01;

and accessed the game object itself with a simple Transform... So simple once you get it! I hope this is helpful to someone though.