What am I doing wrong? (Javascript Variables)

These are my events. Actually, I am trying to make something more complex (I don’t know coding, I just found the code that I need in Stack Overflow), but I think it’s easier to express my problem using this example.

I want to set a variable using javascript and then modify the text using GD events. I did what I showed you, but when i click CheckRoundButton, the text changes to “0”. What am I doing wrong?


1 Like

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

1 Like

It worked, thank you!