MV Variable call in script not working?

Hey folks,

So I'm writing out a script to help with a small feature of mine.

Near the beginning of the plugin I'm declaring a variable that is the same value of the ingame value.

ex

var x = $gameVariables.value(1);

When I go to test the code, it keeps throwing me a null error. The variable has a value of 1 when check with the console.

any thoughts?
What is the context/scope of your plugin? $gameVariables isn't defined until a game is loaded or a new game is started, so if you have that command at the highest level rather than in some kind of Game_... class or something like that, it won't work.
Yeah that would be my problem, I'm trying to define it before the game even loads. Okay thank you.
Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/variable-call-in-script-not-working.133574/