A global variable would be anything defined outside one of the event handler functions. As a best practice, though, you should store such things in an object specific to your script, so that you don't run the change of clashing variable names with someone else's script; this sort of "pseudo-namespacing" can be seen in most scripts people have shared: var MyScriptNamespace = MyScriptNamespace || {}; // This lets you share your namespace between scripts/tabs safely MyScriptNamespace.MyGlobalVar = 'Hello, World'; on('ready', function() { log(MyScriptNamespace.MyGlobalVar); }); However, another option is to store data in the state object. Whereas your global variables will be re-initialized every time your script sandbox spins up, the state object is saved, and persists between game sessions. There's nothing special about accessing the state object; it's simply a javascript object named "state" that you can put stuff in. It would be a good idea to "namespace" the data you put into state, though, just in case your script ever gets mixed with someone else's trying to write to the same properties of state. For your specific problem, personally I would simply use a roll query (eg, /roll 1d20+?{Query Text|0}), or calculate the difference manually after the fact. Transient bonuses and penalties aren't usually worth automating, in my opinion.