How to constantly update guiText Object?

I have two scripts. I’ve looked through various questions and got no help for it whatsoever. I haven’t coded in a good few months, So i’m a bit rusty.

I have the updater for the text under Update(), And i checked that it updates at least once, However, It gets stuck at 100.

Here are my two scripts:

Sanity.cs:

`
using UnityEngine;

using System.Collections;

public class Sanity : MonoBehaviour {
	int SanityLevel = 100;
	int Wave = 1;
	public static int EnemiesDefeated = 0;
	int WaveRequirement = 10;
	public static int TotalEnemiedDefeated = 0;
	public static string SanityString;

	// Use this for initialization
	void Start () {
		SanityString = SanityLevel.ToString ();
		InvokeRepeating("SanityDecrease", 0, 1);
		//InvokeRepeating("OnGUI", 0, 1);
	}

	// Use this for GUI
	/*void OnGUI () {
		GUI.Label (new Rect (10, 10, 100, 20), "Sanity: " + SanityString);
	}*/

	
	// Update is called once per frame
	void Update () {
		if (EnemiesDefeated == WaveRequirement) {
			SanityLevel += WaveRequirement;
			EnemiesDefeated = 0;
			WaveRequirement += WaveRequirement;
		}
	}

	void SanityDecrease(){
		SanityLevel -= 1;
	}
}

`

SanityDisplay.cs:

`
using UnityEngine;
using System.Collections;

public class SanityDisplay : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		guiText.text = "Sanity :" + Sanity.SanityString;
	}
}

`

SanityDisplay.cs is supposed to update the amount of sanity left. Sanity.cs is supposed to handle sanity, the wave, and how many enemies have been killed.

your line of code

SanityString = SanityLevel.ToString ();

Is only called once on the Start() function. Put it inside the Update() function and it will work (though it’ll be more efficient to put it where you change the value of SanityLevel).

By the way, you could change your line

guiText.text = "Sanity :" + Sanity.SanityString;

To

guiText.text = "Sanity :" + Sanity.SanityLevel;

And you’d never have to have SanityString at all, saving some code and memory. Except that you’d have to make SanityLevel public, not sure if you want that or not.
When you add an int to a String, it automatically gets converted to a string, so you don’t need to call the function to cast it.