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
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â
This. Unexpected symbol almost always has something to do with what comes immediately before the symbol listed in the error.
Thanks alot to you both!
Youâre welcome
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?
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.