Get GUITexture At Runtime (Using Scripting)

I have been searching for hours on end trying to find the answer to this one, very simple (well, I thought it was) question.

I have a prefab of a cube which is instantiated at runtime. This cube is a cactus block. It has a script attached to it which looks like this:-

var obj : GUITexture;

function Start(){
	obj = GameObject.Find("Health").getComponent(GUITexture);
}

function OnTriggerEnter() {
	obj.pixelInset.width -= 2;
}

The GUITexture was created by going “Create > GUITexture” and not at runtime.

I want it so if the OnTriggerEnter is true then it will change the width by 2. The OnTriggerEnter works like it is supposed but 4 (setting obj variable at runtime) is not setting the obj variable to the GUITexture I have called Health.

Health has no tags on. How can I get the set the obj to GUITexture?

Thanks,

LucasMars123

You have a minor misspelling issue here. line 4 should read

obj = GameObject.Find("Health").GetComponent(GUITexture);

using UnityEngine;
using System.Collections;

public class GUIController : MonoBehaviour {

public Texture2D yourtexture;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI()
{
GUI.DrawTexture(new Rect(10,10,60,60), yourtexture);
}
}