I don't know how to fix it but I know what's causing it, $ creates a variable (a number basically), you can't make a number into a name just doesn't make sense
You need to state which Story Format you are using when you ask a question, as answers can be different for each one. Based on the syntax of your example I will assume you are using Harlowe.
Comments
Try using the (set:) macro instead