Collectables in C#

Hello

I’ve been working on a game, and in said game, the goal is to collect a certain number of notes before you can progress to the next level.

The only problem here is that I can’t seem to figure out how to get this system to work. This is the code I have attached to an empty gameobject in the scene:

alt text

Then, in the PickUpNote script attached to the player, specifically at the part where the note model is destroyed, I’ve added this line:

Collectibles.collected++;

The problems I’m seeing now:

  • The errors in the Collectibles script. It doesn’t seem to recognize the variables I just declared in the same script, and not even the ‘if’-statement.
  • The GUI box doesn’t seem to show itself.

I feel like I’ve made a very dumb and basic mistake but I can’t seem to find it. Can anyone help me with this?

  1. Your if statement lies outside of every function. Put the statement inside the OnGUI() function.
  2. It should be OnGUI() instead of onGUI().

The if statement is outside any function.
Within the if statement you assign to collected with = and should compare with ==