An error I can't explain

I’m getting an error that is saying:

The code it’s saying that about is:

while the player has the key-ring: if the key-ring is unnoted: increase the score by 1; now the key-ring is noted;

Can anyone explain this for me?

As the error message suggests, you are probably trying to write an “every turn” rule:

Every turn while the player has the key-ring:
[…]

You always have to tell Inform when to run your code. There are basically three ways to do this (correct me if I’m wrong, people). First, there are declarations that set up the initial world model, variables, and so on. Examples:

Church is a room. John is a man in church. The current piety is a number that varies. The current piety is 0.

Then, there are rules. Every rule should be either named, or placed in a rulebook (or both). So we can have

This is the blossom shaking rule: say "The summer breeze shakes the apple-blossom."

or we can have

Every turn: say "The summer breeze shakes the apple-blossom."
Note that the former piece of code will do nothing until you add the rule to some rulebook. The latter piece of code will be run whenever the “every turn” rules are run, which is, as the name suggests, every turn.

Finally, you can set up code by defining a routine that can be called from elsewhere in your code.

To shake the blossom: say "The summer breeze shakes the apple-blossom."
And this can be invoked by stating “shake the blossom”.

Your original code has none of these forms. It is just some code existing in limbo. Inform would never know when to run it. What happens is that the compiler attempts to understand the code as a rule, cannot find the right syntax, and throws an error.

Small nitpick: There is a way for a rule to have an effect without being placed in a rulebook. If you have this code:

This is the blossom shaking rule: say "The summer breeze shakes the apple-blossom."

you can make it run from within another rule by explicitly invoking it, something like this:

Every turn when the location is Orchard: abide by the blossom-shaking rule.

This is discussed in section 18.13 of the manual, and example 292, “Pages,” lets you see how a standalone rule might be invoked by other rules in this way.

But for the most part, you definitely want to put your rules in rulebooks.

It works, thanks! Helps a lot.