Problem with an "Upgrade Script"

I can buy the first two upgrades in a "pause menu". (Which this script is a part of).

However, once I reduce the rate of fire (Rclick.reloadTime) to .8 seconds it simply wont do anything passed that.

if (GUI.Button (Rect(0 + Screen.width * .4, 0 + Screen.height * .4, Screen.width * .05, Screen.height *.05),buttonPlus))
    {
    if (RClick.reloadTime == 1.0 && NPCSpawning.playerScore >= 5)
        {
        RClick.reloadTime-=0.10;
        NPCSpawning.playerScore -=5;
        print ("upgrading to .9");
        return;

        }
    if (RClick.reloadTime == 0.9 && NPCSpawning.playerScore >= 10)
        {
        RClick.reloadTime -=0.10;
        NPCSpawning.playerScore -=10;
        print ("Upgrading to .8");
        return;
        }

    if (RClick.reloadTime == 0.8 && NPCSpawning.playerScore >= 15)
        {
        RClick.reloadTime -=0.10;
        NPCSpawning.playerScore -=15;
        print ("Upgrading to .7");
        return;
        }
    if (RClick.reloadTime == 0.7 && NPCSpawning.playerScore >= 20)
        {
        RClick.reloadTime-=0.10;
        NPCSpawning.playerScore -=20;
        return;

        }
    if (RClick.reloadTime == 0.6 && NPCSpawning.playerScore >= 25)
        {
        RClick.reloadTime-=0.10;
        NPCSpawning.playerScore -=25;
        return;

        }

    if(RClick.reloadTime == 0.5)
        {
        print ("Already maxed");
        return;
        }
        }

I have a similar button to "sell back" upgrades and it too won't work at .8 seconds.

I'm at a loss. I don't receive any errors and to me the script portion at .8 seconds looks the same as the rest. I tested it so that upgrading from .9 to lower seconds reduced it by .20 (skipping .8) and it worked just fine.

Maybe it's a syntax problem I'm not aware of?

You're having issues with floating point precision, or round offs.

Check out this test to verify this:

// Test assumption that 0.9 - 0.1 is 0.8 with floating point math.
function Start() {
    var actual = 0.9;
        actual -= 0.1;
    var expected = 0.8;
    var result = (actual == expected) ? "Test Passed" : "Test FAILED";
    print(String.Format("{0} == {1} : {2}", actual, expected, result));
    // Outputs:   0.8 == 0.8 : Test FAILED
    // Assumed:  0.8 == 0.8 : Test Passed
    // The formatting doesn't pick up the true number 
    // (probably something like 0.8000001 or 0.7999999)
}

This is a common problem when subtracting with floating point values. You might want to use ranges like `if (RClick.reloadTime >= 0.9 && NPCSpawning.playerScore >= 10)`, or use Mathf.Approximately, or change to integers all together.

From Mathf.Approximately:

Due to floating point imprecision it is not recommended to compare floats using the equal operator. eg. 1.0 == 10.0 / 10.0 might not return true.

I wouldn't trust floating point values for any greater precision, especially not when subtracting. I've been caught in many endless loops due to those errors.