Why isn't my simple coroutine working? (and how can I make it infinite?)

So far there is no errors and the text displays properly on the GUI but it only displays the starting amount even though I have a Coroutine that updates that amount, heres what I have so far(c#):

public class Money : MonoBehaviour {
public float cashInInventory = 100;
public float cashEarnAmount = 50;
public Text spendingCash;

 void Start () {
     spendingCash = GetComponent<Text>();
     StartCoroutine("GiveCash");
 }
 private IEnumerable GiveCash()
 {
     while (true)
     {
         yield return new WaitForSeconds(5.0f);
           cashInInventory += cashEarnAmount;  
     }
 }
 
 // Update is called once per frame
 void Update () {
     spendingCash.text = cashInInventory.ToString("f0");
     print(cashInInventory);
 }
}

StartCoroutine("GiveCash"); should be StartCoroutine(GiveCash());

And I’m pretty sure you want GiveCash() to return IEnumerator instead of IEnumerable.

StartCoroutine("GiveCash") would work too, the issue is the return type not being IEnumerator.

You don’t need to use a coroutine though, for something this simple you can use Time.time:

float lastCashEarnedAt = 0f;

void Update() {
    if (Time.time - lastCashEarnedAt >= 5f) {
        GiveCash();
    }
}

void GiveCash() {
    cashInInventory += cashEarnAmount;
    lastCashEarnedAt = Time.time;
}