[Solved] 'public' is unexpected. Why?

Assets/NumberWizard.cs(5,9): error CS1041: Identifier expected: public' is a keyword, and Assets/NumberWizard.cs(25,14): error CS1525: Unexpected symbolpublic’.
using UnityEngine;
using System.Collections;
using UnityEngine.UI

public class NumberWizard : MonoBehaviour {
// Use this for initialization
int max;
int min;
int guess;
int maxGuessesAllowed = 10;

public Text text;

void Start () {
	StartGame ();
}

void StartGame () {
	max = 1000;
	min = 1;
	guess = 500;

	
	
public void GuessLower(){
	max = guess;
	NextGuess ();
}

public void GuessHigher(){
	min = guess;
	NextGuess ();
}

void NextGuess () {
	guess = (max + min) /2;
	text.text = guess.ToString();
	maxGuessesAllowed = maxGuessesAllowed - 1;
	if (maxGuessesAllowed <= 0){
		Application.LoadLevel("Win");
	}
}

}

Hello @Ubae_Malla, how are you? Welcome to this course :slight_smile:
You are missing an closing curly brace in the StartGame() method.

1 Like

Thank you so much! This really helps but it is still saying that public is a keyword and processing it as an error. Thanks a lot though!

1 Like

@Ubae_Malla Can you re-post your code after you have made the amendment suggested by @Joao_Dalvi

1 Like

Sure thing. ` using UnityEngine;
using System.Collections;
using UnityEngine.UI

public class NumberWizard : MonoBehaviour {
// Use this for initialization
int max;
int min;
int guess;
int maxGuessesAllowed = 10;

public Text text;

void Start () {
	StartGame ();
}

void StartGame () {
	max = 1000;
	min = 1;
	guess = 500;
}
	
	
public void GuessLower(){
	max = guess;
	NextGuess ();
}

public void GuessHigher(){
	min = guess;
	NextGuess ();
}

void NextGuess () {
	guess = (max + min) /2;
	text.text = guess.ToString();
	maxGuessesAllowed = maxGuessesAllowed - 1;
	if (maxGuessesAllowed <= 0){
		Application.LoadLevel("Win");
	}
}

}`

You forgot the semicolon after using UnityEngine.UI :wink:

Ugh, thanks to you as well. I just miss so many small things, it’s annoying. I just need to practice not doing that. Thanks again!

No problem, practice is how you get used to those kinds of errors :slight_smile:

Totally.