'Time' does not contain a definition for 'timeScale'

I have not had problems with this script in the past… and all of a sudden it has started doing this: ‘Time’ does not contain a definition for 'timeScale’

using UnityEngine;
using System.Collections;

public class PauseScript : MonoBehaviour {

public GameObject transGray;
public GameObject playButton;
public bool paused;

void Start () 
{
	paused = false;	
	playButton.SetActive(false);
	transGray.GetComponent<Renderer>().enabled = false;

}

void Update () 
{

}

public void Pause()
{
	paused = !paused;

	if (paused) 
	{
		Time.timeScale = 0f;
		playButton.SetActive(true);
		transGray.GetComponent<Renderer>().enabled = true;
	} 
	else if (!paused) 
	{
		Time.timeScale = 1f;
		playButton.SetActive(false);;
		transGray.GetComponent<Renderer>().enabled = false;
	}
}

}

1 Like

You’ve probably named one of your scripts “Time”, which is overriding the built-in Time class. Rename the file (and the class definition inside) to something else, like “MyTime”.