GUI, get a float to always be at 200 pixels?

I’m trying to create a Health Bar that displays onscreen as 200x25, I started off with 100 as the Health and where the width is set I set that to the Float for the Health but since I’m now adding levels that increases the health I can’t seem to figure out a way of always ensuring that the GUI scales it down to 200 pixels despite what size the Health value is.

You can use a factor that indicates relation between health value based on level and pixels and use that factor to convert your health value into pixel values.

Something like:

float MaxHealthValue;  // This is the maximum health value based off the level
float noOfPixels;  // Number of pixels to use to display the health bar. In your case this will be 200
float healthToPixelsFactor;

void Start()
    // Calculate the value for the factor
    healthToPixelsFactor = noOfPixels / MaxHealthValue;

void Update()
    // Now you can calculate the length in pixels for your health value as below
    pixelLength = healthValue * healthToPixelsFactor;