Global variable declared but "not declared in this scope" error

Thanks, I was going to post the answer myself. I just found it five minutes after my message, although I've been searching for it for hours before... Murphy's law!