NVM

I keep getting the error "The type or namespace name ‘MonoBehavior’ could not be found (are you missing a directive or an assembly reference?) on my code (Attached) and I’m relatively new to coding so I followed a guide, I’m sure somebody that is more experienced can easily spot the error.

using System.Collections;
public class PlayTimer : MonoBehaviour
{
public int playtime = 0;
private int seconds = 0;
private int minutes = 0;
private int hours = 0;
private int days = 0;
void Start()
{
StartCoroutine(“playtimer”);
}
private IEnumerator playtimer()
{
while (true)
{
yield return new WaitForSeconds(1);
playtime += 1;
seconds = (playtime % 60);
minutes = (playtime / 60) % 60;
hours = (playtime / 3600) % 24;
days = (playtime / 86400) % 365;
}
}
void OnGUI()
{
GUI.label(new Rect(50, 50, 400, 50), "Playtime = " + days.ToString() + " Days " + hours.ToString() + " Hours " + minutes.ToString() + " Minutes " + seconds.ToString() + " Seconds ");
}

}

I figured it out, Nvm

Keep in mind that OnGUI has been deprecated and back-burnered since about 2014, so whatever tutorial you’re getting this from is going to seriously impede your progress with modern Unity. :slight_smile: