– This thread doesn’t exist anymore –
// Use this for initialization
public void ResetFunction() {
if (PlayerPrefs.HasKey("Score") == true)
{
score = 0;
}
}
Put that inside
void start () {
}
wont do?
I would recommend going through the tutorials on how to code in C#, and what the various function on the GameObject mean. This sort of piecemeal programming effort never works out. Of course, he meant for you to change the name of the function to “start”.
score = PlayerPrefs.SetInt(“Score”, 0);
should be
score = 0;
PlayerPrefs.SetInt(“Score”, 0);
And: yes, read tutorials. Those are C# basics. (a method has a return type and SetInt has a return type void) and you can’t assign void to your score, because score is type int.
You need to read the tutorials. Period. You having been asking the community to basically write your game for you line by line, and not learning anything at all. You need to stop and read the docs and tutorials, this is like your 5th topic on trying to do simple scoring. And more importantly you need to stop demanding that people post solutions. You are being very rude and inconsiderate.
If after this many posts and topics you are not learning the very basics, you are either not putting in the effort, (assuming others will write your game for you), or it’s something you are just not capable of in the first place.
Step back, take a break and figure out which it is. You are quickly using up good will from the community. If you keep going like this, people will stop responding at all, and you are at the very easiest part of the game now. If you can’t sort adding and displaying numbers, well… it only gets more difficult.
This thread should be closed, there are already on “scoring” from the OP: