Can't sum all array values into a float var properly

Basically, i can deploy an oil rig in my game, if they find oil, they start extracting it and the user gets 1 dollar per second while the oil deposit is not empty.

In another script, i can count how many oil rigs there are in the scene at the moment and store those gameobjects in an array. This script also stores the money each oil rig is extracting (if is extracting).

The text script, where i show how much money the user has, is where i (try) to sum the money extracted by all oil rigs in the scene:

void Update ()
{
     for (int i = 0; i < noilers.n_oilers; i++)
      {
          finalmoney += noilers.allmoney *;*

}
txt.text = finalmoney + “”;
}
That displays way more money than it actually should, because it’s always incrementing the previous value, but i can’t find a way to sum all oil rig’s money.
Like this, it’ll show the user the correct amount of money he has, but if i try to subtract money in another script (buying items), it’ll go back to the same value the next frame:
void Update ()
{
finalmoney = 0;
for (int i = 0; i < noilers.n_oilers; i++)
{
finalmoney += noilers.allmoney ;
}
txt.text = finalmoney + “”;
}
what i would want should be something like (if i have, for example, 3 active oil rigs):
finalmoney = noilers.allmoney[0] + noilers.allmoney[1] + noilers.allmoney[2]
Probably a pretty stupid mistake but i just can’t figure out how to bypass this

Thanks to my coworker:

for (int i = 0; i <= noilers.n_oilers - 1; i++)
          {
            if (noilers.allmoney *== 1 && x == 1)*

{
x = 0;
noilers.oldallmoney = 0;
}
finalmoney -= noilers.oldallmoney*;*
finalmoney += noilers.allmoney*;*
noilers.oldallmoney = noilers.allmoney*;*
}