SetActive doesn’t work for GameObject


I’m using Unity 2D for my game and I’m facing a weird problem. I have a GameObject (an image) in my scene with a button attached to it. When the player is out of the screen, the image that works as a GameOver panel appears and in case of enough coins, you can resume the game. Everything works fine but when the image appears and I click on button to resume, the image doesn’t disappear while the function for decreasing number of coins still works.

Here is my script in which di() is for die and but() for button:

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using CodeStage.AntiCheat.ObscuredTypes; using CodeStage.AntiCheat.Detectors;  public class UIManager2 : MonoBehaviour {      public static ObscuredInt coin_score = 0;      public Text coin_text;     public Slider slider;     public Slider slider1;     public Slider slider2;     public GameObject bul;     public bool reverse;     public float timer;     public int delay = 1;     public float speed=0.5f;     public GameObject pause;     public AudioSource[] aud=new AudioSource[3];      void Start () {         coin_score = ObscuredPrefs.GetInt ("Score");         StartCoroutine (elapsed ());         slider1.minValue = 0;         slider1.maxValue = 20;         bul = GameObject.FindGameObjectWithTag ("Player").GetComponent<Plane19> ().bullet;     }      void Update () {         timer += Time.deltaTime;         if (timer >= delay && reverse == false) {             timer = 0f;             slider2.value++;         }          if (timer >= delay && reverse == true) {             timer = 0f;             slider2.value -= speed;       }          coin_text.text = coin_score.ToString ();         ObscuredPrefs.SetInt ("Score", coin_score);          if (slider2.value == 10) {             bul.SetActive (false);             reverse = true;         }       if (slider2.value == 0) {             bul.SetActive (true);             reverse = false;         }      }      public void di(){         pause.SetActive(true);         GetComponent<AudioSource>().Pause();         Time.timeScale = 0;         aud[0].Play();         aud[1].Pause();         aud[2].Pause();  }      public void but(){         pause.SetActive(false);         Time.timeScale=1;         aud[0].Pause();         aud[1].UnPause();         aud[2].UnPause();         GetComponent<AudioSource>().UnPause();         UIManager2.coin_score-=2;      }  IEnumerator elapsed () {         yield return new WaitForSeconds (2f);         slider.value++;         StartCoroutine (elapsed ());     } }