Quiz Game Score

Hi… i’m new in unity and i want to make a quiz game and here is the script

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

public class GameManager : MonoBehaviour {

    public Question[] questions;
    private static List<Question> unansweredQuestions;

    private Question currentQuestion;

    [SerializeField]
    private Text factText;

    [SerializeField]
    private Text TrueAnswerText;
    [SerializeField]
    private Text FalseAnswerText;

    [SerializeField]
    private Animator animator;

    [SerializeField]
    private float TimeBetweenQuestions = 1f;

    void Start()
    {
        if (unansweredQuestions == null || unansweredQuestions.Count == 0)
        {
            unansweredQuestions = questions.ToList<Question>();
        }
        SetCurrentQuestion();
    }

    void SetCurrentQuestion()
    {
        int randomQuestionIndex = Random.Range(0, unansweredQuestions.Count);
        currentQuestion = unansweredQuestions[randomQuestionIndex];

        factText.text = currentQuestion.fact;

        if (currentQuestion.isTrue)
        {
            TrueAnswerText.text = "Hebat";
            FalseAnswerText.text = "Maaf";
        }else
        {
            TrueAnswerText.text = "Maaf";
            FalseAnswerText.text = "Hebat";
        }
    }

    void CallGameOverScene()
    {
        SceneManager.LoadScene("GameOverScene");
        Application.LoadLevel("GameOverScene");
    }

    IEnumerator TransitionToNextQuestion()
    {
        unansweredQuestions.Remove(currentQuestion);

        yield return new WaitForSeconds(TimeBetweenQuestions);

        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    }

    public void UserSelectTrue()
    {
        animator.SetTrigger("Benar");
        if (currentQuestion.isTrue)
        {
            Debug.Log("Hebat!");
            StartCoroutine(TransitionToNextQuestion());
        }
        else
        {
            Debug.Log("Maaf");
            CallGameOverScene();
        }

    }

    public void UserSelectFalse()
    {
        animator.SetTrigger("Salah");
        if (!currentQuestion.isTrue)
        {
            Debug.Log("Hebat!");
            StartCoroutine(TransitionToNextQuestion());
        }
        else
        {
            Debug.Log("Maaf");
            CallGameOverScene();
        }

    }
}

how to make a scoring and final score on game over scene ?
Thx before
Ps; i’m following tutorial brackeys to make this script :slight_smile:

create a score script like this

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

public class ScoreScript : MonoBehaviour {

public static int scoreValue = 0;
Text score;
// Use this for initialization
void Start () {
	score = GetComponent<Text> ();
}

// Update is called once per frame
void Update () {
	score.text = "Answered :" +scoreValue;
}

}

go to gamemanager script add in

IEnumerator TransitionToNextQuestion()
{
unansweredQuestions.Remove(currentQuestion);

     yield return new WaitForSeconds(TimeBetweenQuestions);

     ScoreScript.scoreValue += 1;

     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
 }

Hello I have the same issue, when I added the “Score.scoreValue += 1;” into The IEnumerator the score keeps increasing no matter if it’s correct or false.
I then tried adding it within the animator trigger function, it works now only when it’s a correct answer but if you spam click the score keeps increasing. Any help would be appreciated.

public void UserSelectTrue()
    {

        animator.SetTrigger("True");
        if (currentQuestion.isTrue)
        {

            Debug.Log("CORRECT");
            Score.scoreValue += 1;

        }
        else
        {
            Debug.Log("FALSE");

        }

        StartCoroutine(TransitionToNextQuestion());
    }