Time.timeScale is a static value. Anything else would make no sense frankly, because a game can't run at multiple speeds at the same time. But that also means, that you have to be careful where you set it from.
Generally speaking, you would have some kind of GameManager that is a singleton and takes care of setting values like this, instead of individual scripts doing it.
If you don't know what a singleton is, look it up; it's very useful to know (though it should not be overused either).
Assuming you have such a GameManager, the implementation I mentioned above would look somewhat as follows.
First, you will need a variable in your manager to store all objects that want the game to be paused:
private readonly HashSet<MonoBehaviour> pauseRequestors = new HashSet<MonoBehaviour>();```
I am using a `HashSet` here, because those cannot contain the same object multiple times (which will managing the whole thing easier).
Second, you'll want to create methods in your manager to pause and unpause the game (or, more precisely, add and remove pause requestor instances): ```cs
public void Pause(MonoBehaviour req)
{
if(req != null)
{
pauseRequestors.Add(req)
UpdatePause();
}
}
public void Unpause(MonoBehaviour req)
{
if(req != null)
{
pauseRequestors.Remove(req)
UpdatePause();
}
}
public void ForceUnpause()
{
pauseRequestors.Clear();
UpdatePause();
}
private void UpdatePause ()
{
Time.timeScale = pauseRequestors.Count > 0 ? 0f : 1f;
}```