How to make this text update with timer value

Need to know how to make “boostTimerText” update with correct value since im using co-routines. The valuse of the timer is the “wait” of the co-routine.

using UnityEngine;
using System.Collections;

public class Timer : MonoBehaviour {

	public Main mainScript;
	public ulong mps = mainScript.mps;
	public ulong oldmps;
	public GUIText boostTimerText = mainScript.boostTimerText;

	// Use this for initialization
	void Start () {
		StartCoroutine(MoneyPerSecond (1f));
		StartCoroutine(BoostTimer (500f));
	}
	
	// Update is called once per frame
	void Update () {
		boostTimerText.text = "Timer: ";
	}

	public IEnumerator MoneyPerSecond (float wait) {
		yield return new WaitForSeconds(wait);
		Money += mps;
		StartCoroutine(MoneyPerSecond (1f));
	}
	
	public IEnumerator BoostTimer (float wait) {
		yield return new WaitForSeconds(wait);
		oldmps = mps;
		mps *= 5;
		StartCoroutine(BoostTimer (500f));
	}
}

a couple of things stand out:

  1. you need to get a reference to the mainScript component, checking for null, etc. Find()/GetComponent()/etc. you might be doing it in the inspector, but that’s clear.

  2. there’s no need to include the StartCoroutine() in the coroutines… much easier to do something like the following if the wait time isn’t changing.

    public IEnumerator MoneyPerSecond (float wait)
    {
    while(true) // Always
    {
    yield return new WaitForSeconds(wait);
    Money += mps;
    }
    }

  3. your Update() function isn’t changing the value of anything, so Update() probably isn’t the best place for it…

  4. you haven’t defined Money anywhere in this script. if you’re getting errors, then you’ll need to include that info too - help us help you.

EDIT:
for 3) it seems like you are actually asking how to set the timer text to the elapsed time.

easiest way to do that is to store Time.time in the Start()/Awake() function in some private variable (_preservedTime) then your displayed update time will be

(Time.time - _preservedTime)