NaN error when trying to adjust Scale as a percentage.

All i’m trying to do is adjust the scale of my object to the percentage of player health remaining everything works the way it’s supposed to at run time, however I get an error on every update that reads:

transform.localScale assign attempt for ‘HealthTexture’ is not valid. Input localScale is { NaN, 1.000000, 1.000000 }.

	void Update () {
		healthPercentage = playerCurrentHealth / playerMaxHealth;
		transform.localScale = new Vector3(healthPercentage,1,1);

So if anyone does stumble upon this, I ended up just checking to see if my float was returning NaN and then setting it to 0 if it was to keep the variable from ending up undefined. I’m still not sure why even if the number is valid why I was still getting a NaN error.

		healthPercentage = playerCurrentHealth / playerMaxHealth;
		if (float.IsNaN (healthPercentage)) healthPercentage = 0;
		if (healthPercentage > 1f) healthPercentage = 1f;
		transform.localScale = new Vector3 (healthPercentage, 1, 1);