[Solved] Set global variable with javascript?

I´m running Gdevelop5 and are wondering if its possible if so how do one set a new value to a global variable trough java script ? tried searching for it for the last few weeks !

Thanks in advanced,


Set value of global variable:
runtimeScene.getGame().getVariables().get(“globalVarName”).setString(“new text”);

Get value of global variable:
var globalVarNumber = runtimeScene.getGame().getVariables().get(“globalVarName”).getAsNumber();
var globalVarString = runtimeScene.getGame().getVariables().get(“globalVarName”).getAsString();
1 Like

Worked flawlessly !
Thanks for the fast response and help ! <3
Now i can continue with my blockchaingamifications :smiley: !

1 Like