I’m trying to add a label to show the game score and it keeps coming up with this error, the last line is the label I’m trying to add, it keeps giving me this “error CS0029: Cannot implicitly convert type void' to
string’” error message, at the last line
public class EndSceneScript : MonoBehaviour {
//The texure to be drawn for the splash screen
public Texture2D backGroundTexture;
//width and height of button
public int buttonWidth=100;
public int buttonHeight=30;
//the space between the buttons
public int buttonSpacing=70;
//the start Y position of button
public int buttonYStart=300;
string nameText="";
int score;
void OnGUI(){
//create splash screen
GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height),backGroundTexture);
//store the start position
int buttonyPosition=buttonYStart;
//add button
if (GUI.Button (new Rect(Screen.width/2-buttonWidth/2,
buttonyPosition,buttonWidth,buttonHeight), "Main Menu"))
{
GameObject gameData=GameObject.Find("GameData");
if (gameData!=null){
GameDataScript gameDataScript=gameData.GetComponent<GameDataScript>();
gameDataScript.playerName=nameText;
nameText=GUI.Label(new Rect(Screen.width/2-100.0f,50.0f,100.0f,20.0f),nameText+" Score:"+gameDataScript.score);