GUI Texture

I am trying to create a health bar for an enemy which follows the enemy on the screen above its head. Everything works fine, however I have a problem with the GUI Texture component when I try to change the width via java.
Here is the code:

    var HealthPercentage:float;
    HealthPercentage = Health/StartingHealth;
	
	if(transform.FindChild("HealthBar"))
	{
		var barStart:float;
		var barWidth:float;
		barStart = transform.FindChild("1x1Border").GetComponent(GUITexture).guiTexture.pixelInset.width;
		barWidth = barStart*HealthPercentage;
	}

what you can do is draw the background, then use begingroup to limit whats viewable of the next texture

GUI.DrawTexture(//your background
GUI.BeginGroup(new Rect(0, 0, width to use, height))
GUI.DrawTexture(new Rect(0,0,originakWidth,height), //your health bar
GUI.EndGroup();