Grading system not working

Hello everyone,

I am trying to create a grading system on my game so by the end of it, depending on the score, the user gets the matching grade. Bare with as I am very new at scripting still…

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

public class GradeScript : MonoBehaviour {

private GameController gameController;
public Text gradeText;

void Awake () {
	
gameController = FindObjectOfType<GameController>();
	
}

void Update () {

	if (gameController.score > 700) {
	gradeText.text = "Grade: A+";
	}
	
	if (gameController.score > 600 && gameController.score < 699) {
		gradeText.text = "Grade: A";
	}
	
	if (gameController.score > 500 && gameController.score < 599) {
		gradeText.text = "Grade: B";
	}
	
	if (gameController.score > 400 && gameController.score < 499) {
		gradeText.text = "Grade: C";
	}
	
	if (gameController.score > 300 && gameController.score < 399) {
		gradeText.text = "Grade: D";
	}
	
	if (gameController.score > 200 && gameController.score < 299) {
		gradeText.text = "Grade: E";
	}
	
	if (gameController.score > 100 && gameController.score < 199) {
		gradeText.text = "Grade: F";
	}

}

}

This is not working for me. I am getting no errors but it’s not showing up in the final scene (Grading scene). Can you please help me? Thank you.

I don’t necessarily see anything wrong with your code, though it’s a lot more verbose than necessary. The following is probably a little cleaner (though typed directly into the forum and untested).

void Update()
{
   int score = gameController.score; 
   if (score > 700) { gradeText.text = "Grade: A+"; }
   elseif (score > 600) { gradeText.text = "Grade: A"; }
   elseif (score > 500) { gradeText.text = "Grade: B"; }
   elseif (score > 400) { gradeText.text = "Grade: C"; }
   elseif (score > 300) { gradeText.text = "Grade: D"; }
   elseif (score > 200) { gradeText.text = "Grade: E"; }
   else { gradeText.text = "Grade: F"; }
}

Additionally, you probably need to add some Debug.Log statements to see what’s going on. For instance, is the score value what you expect it to be? Also, this seems like a strange thing to be doing in Update(). Is that really what you want?