Score won't update when correct answer is selected?

Hi,

I’m trying to get the score to update when the player chooses the correct answer.
For the first question the score will update when the correct answer is selected but for the second question the pop up box will just close and the score won’t be updated?

The scripts are near identical just the question and answers are different.

using System;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Question1 : MonoBehaviour {
  
    private Rect windowRect = new Rect (500, 100, 400, 200); //Window size
    public bool question1;
    private int count;
    public Text countText;

  
    void start()
    {
        count = 0;
        SetCountText ();
    }

    
    void OnGUI()
    {
        windowRect = GUI.Window (0, windowRect, WindowFunction, "Ebola Quiz Island"); //window on screen
    }
  
  
    void WindowFunction (int windowID)
    {
        // Draw any Controls inside the window here

        GUI.Label (new Rect (30, 25, 200, 50), " What year did Ebola begin?"); // Question
      
        if (GUI.Button (new Rect (20, 100, 100, 30), "1976")) // Correct Answer
        {

            Destroy (this.gameObject);
            count = count + 1;
            SetCountText ();
        }

        if (GUI.Button (new Rect (280, 100, 100, 30), "1986")) //Wrong answer
        {
            Destroy (this.gameObject);
            Application.LoadLevel(Application.loadedLevel);
        }

        if (GUI.Button (new Rect (20, 150, 100, 30), "1996")) // wrong answer
        {
            Destroy (this.gameObject);
            Application.LoadLevel(Application.loadedLevel);
        }

        if (GUI.Button (new Rect (280, 150, 100, 30), "1966")) // wrong answer
        {
            Destroy (this.gameObject);
            Application.LoadLevel(Application.loadedLevel);
        }
    }

    void SetCountText()
    {
        countText.text = "Score: " + count.ToString ();
    }

}
using System;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Question2 : MonoBehaviour {
  
    private Rect windowRect = new Rect (500, 100, 400, 200); //Window size
    public bool question2;
    private int count;
    public Text countText;

    void start()
    {
        count = 0;
        SetCountText ();
    }
  
    void OnGUI()
    {
        windowRect = GUI.Window (0, windowRect, WindowFunction, "Ebola Quiz Island"); //window on screen
    }
  
  
    void WindowFunction (int windowID)
    {
        // Draw any Controls inside the window here
        GUI.Label(new Rect (30, 25, 300, 50), " What is the Ebola virus named after?"); // Question
      
        if (GUI.Button (new Rect (20, 100, 100, 30), "A river")) //Correct answer
      
        {
            Destroy (this.gameObject);
            count = count + 1;
            SetCountText ();
        }


        if (GUI.Button (new Rect (280, 100, 100, 30), "A farm")) // Wrong answer
        {
            Destroy (this.gameObject);
            Application.LoadLevel(Application.loadedLevel);
        }
       
        if (GUI.Button (new Rect (20, 150, 100, 30), "A tree")) // Wrong answer
        {
            Destroy (this.gameObject);
            Application.LoadLevel(Application.loadedLevel);
        }

        if (GUI.Button (new Rect (280, 150, 100, 30), "A city")) //Wrong Answer
        {
            Destroy (this.gameObject);
            Application.LoadLevel(Application.loadedLevel);
        }
    }

    void SetCountText()
    {
        countText.text = "Score: " + count.ToString ();
    }

}

The score does update, it’s just that the score isn’t cumulative. You set the Text to your count variable, but that variable is a private one for each Question script. You increase the count only for that question when you guess a right answer, so you can never have more than 1 point.

You need to change the way the question scripts are set up. You need to have a script that holds the total score variable, either on a GameObject instance, or in a static variable. Also, while you’re refactoring, make a generic QuestionWindow script in which you write the questions in public variables, instead of copy pasting the code for each question - that will come back to bite you in the bum when you want to change something.