timeScale is being set to 1 instead of staying set at 0,How to fix the timeScale?

139140-code.png

I’m having a problem with the script above. The problem is that when the script is run (the script is on a separate canvas), the timeScale of the canvas that is being overlapped by the script canvas’ timeScale is being set to 1, when the timeScale should be set to 0. In short, the background of the canvas where the script is, is setting its own timeScale to 1 instead of setting and keeping the timeScale at 0, where it should be when the script canvas is called…

Anyone have any ideas how to fix this?,139140-code.png

I’m having a problem with this code that I can’t figure out. The problem is when I run the scene in Unity, once the script above is called (the script itself is on another canvas), the canvas in the background’s timeScale gets set to 1. The canvas in the background’s timeScale is supposed to be set to 0 when the canvas where the script is on is opened, but the timer sets the timescale back to 1…

Anyone have any ideas on how to possibly fix this?

so there is an object in the game that once destroyed sets time scale to 0. And then a canvas appears that has a timer. Since the time scale is set to 0 the timer doesn’t work, but the time scale needs to be set to 0 for other aspects of the game.
Is there a way to allow the timer to has timescale of 1 for example, while the rest of the game is set to timescale of 0?

Here you have the code just override your coroutine

IEnumerator LoseTime()
{
    while (timeLeft> 0) {
        yield return null;
        timeLeft -= Time.unscaledDeltaTime;
    }
}