GUIText not changing

Hi All,

I am sure this is an easy fix but I can’t for the life of me figure out where I am going wrong. I have a restart button and a score displaying. The Restart text and button work but the score does not display anything except Score Text. This is my code:

using UnityEngine;
using System.Collections;

public class HighScore : MonoBehaviour
{
public GUIText scoreText;
public GUIText restartText;

float playerScore;

void PlayerScore()
{
scoreText.text = "Score: " + PlayerPrefs.GetFloat(“playerScore”);
}
void Update()
{
restartText.text = “”;
restartText.text = “Press ‘R’ for Restart”;
if (Input.GetKeyDown(KeyCode.R))
{
Application.LoadLevel(“Main”);
}
}
}

For now I am only starting out with a very basic idea of showing my Score on this screen. I have tried changing the scoreText.text = “I don’t work” and when I run the game it still only displays Score Text. I am sure it is probably something really easy I am missing.

Thanks.

GUIText is deprecated and has been replaced by Text, and to use it you may need to include ‘using UnityEngine.UI;’
If these adjustments don’t resolve it, make sure that your scoreText is being correctly pointed to.

Ok so I knew it would be a simple fix. In the end I had to put the scoreText.text and restartText.text in the same void.

just a note on terminology. “void” is a return type, it makes no sense to put something “in a void” since it is by it’s definition “nothing”; you probably want to use the word “function” or “method” :slight_smile: