[Solved] Expression in a Global Variable Name


I need to add a value to a Global Variable, but I also need to use an expression in the Global Variable name. I tried this, but it doesn’t work.

How can I solve?

To clarify: Base Variable names, object names, and layer names are not strings. They are references. You cannot use expressions when referencing any of these.

Child variable names can be accessed via expression, however.

Your screenshot should work fine only if you’re accessing the child variable of a structure or array variable.


You have a parent variable named myVariable. It is a structure variable, with a child variable named “testChild”. It is also a structure variable, and has a child of “id”. The value of id is 4.

You have another scene variable named “findChild”, it is a string variable with the current string of “testChild”.

Using “Change the global variable:add 1” with the variable of
myVariable[VariableString(findChild)][“ID”], will make the variable mentioned above be set to 5.

Note: You cannot use VariableString, Object.VariableString, or GlobalVariableString expressions unless the actual variable is a string variable. If your variable is a value (number) or boolean, you will have to use ToString() to convert it to a string. e.g. myVariable[ToString(Variable(findChild))][“ID”]

Hello and thank you very much for your reply, full of useful tips.

I’m sorry though, the problem was in the last parenthesis. Two days of work for a classic syntax error! :face_with_open_eyes_and_hand_over_mouth:

1 Like

No apologies needed. I missed it too. :smiley: