- Home /
Scripting error
Hello. I got this script this thread that I started. I am trying to use it to control the highscores in my game, but I keep getting this error ""Assets/NewBehaviourScript.js(3,19): BCE0018: The name 'string' does not denote a valid type ('not found'). Did you mean 'System.Runtime.CompilerServices.StrongBox'?" " what is wrong? Thanks
function Update () {
var key : string = System.String.Format("{0}{1}{2}_score", Arcade.ModeInt, Arcade.DifficultyInt, Arcade.CharacterInt);
PlayerPrefs.SetString(key, Stats.Score);
}
Like the error said, 'string' is not a valid type. You can use 'String', or leave it out...System.String stuff all returns a String, naturally, so 'key' is always a String anyway. LOL @ the suggested replacement though.
Answer by uhahaha · Dec 19, 2010 at 12:44 AM
string -> String
heh, thanks. I fixed that and I get this error "Assets/NewBehaviourScript.js(3,30): BCE0017: The best overload for the method 'UnityEngine.PlayerPrefs.SetString(String, String)' is not compatible with the argument list '(String, int)'."
Thats because you want to set a string (You call SetString) but pass in an integer (Stats.Score is an integer). What you probably want to do is call SetInt ins$$anonymous$$d of SetString. Another option (I doubt you want to do this though:) is to convert the int to a string; Stats.Score.ToString().
Your answer

Follow this Question
Related Questions
Number of played games 1 Answer
Get PlayerPrefs file path directly at runtime? 0 Answers
I can't save my money? :< 1 Answer
PlayerPrefs not storing string? 0 Answers