[Unsolved] [Error] "Unexpected Symbol 'HighScore'"

Hi,
i am a beginner working on my first game with c# and i was attempting to code in a high score system using playerprefs. i am unsure how to fix this and would appreciate it if someone could give me a hand.
-Thanks in advance.

Please read this : Using code tags properly - Unity Engine - Unity Discussions
it will tell you how to post code nicely into the forums.

Post the code you have & I’m sure someone will assist you with feedback and/or fixes :slight_smile:

1 Like

Okay, you posted a screenshot (not as good as code tags), as I was writing my first post.

Remove the “New” word in your “SetInt”

2 Likes

This. Unexpected symbol almost always has something to do with what comes immediately before the symbol listed in the error.

1 Like

Thanks alot to you both!

You’re welcome :slight_smile:

1 Like

oh, just removed the new from my SetInt and got three more errors.

Assets/Scripts/Score.cs(11,16): error CS1061: Type UnityEngine.UI.Text' does not contain a definition for Text’ and no extension method Text' of type UnityEngine.UI.Text’ could be found. Are you missing an assembly reference?

Assets/Scripts/Score.cs(22,15): error CS1502: The best overloaded method match for `UnityEngine.PlayerPrefs.SetInt(string, int)’ has some invalid arguments

Assets/Scripts/Score.cs(22,36): error CS1503: Argument #2' cannot convert UnityEngine.UI.Text’ expression to type `int’

Yeah, I can see that.
the ‘Text’ error is because you need ‘.text’
The second error, you could fix with int.parse(ScoreText.text). That would also fix error #3.

PS. additional note/question: Is your score based on the position.z in the game??

Yeah it’s a game based on how far you can get arcade type game so it uses the z position.

Cool. Is it working now? :slight_smile:

aww damn, got a new error.
Assets/Scripts/Score.cs(22,15): error CS0119: Expression denotes a method group', where a variable’, value' or type’ was expected

replied to fix in mail… referred the author to the Learn Section → Scripting.
:slight_smile:

1 Like