Display text with object variable that "points" to global variable

I have a text object called genericTextUpdater with an instance variable called textHere. The textHere variable is the name of a global variable (for example: exp, health). I want the genericTextUpdater to show text of the global variable indicated by textHere. How do I do this?

This is my event:

It doesn’t work. It says “More than one term was found. Verify that your expression is properly written.”

The reason I want to do this is because I’ll have like a hundred different indicators, and I don’t want to write a new event and make a new object for each one. It’s going to get messy and I’d rather just have a different “pointer” variable on each one. I’m open to other ways of doing this, but I’d still like to figure out this method first so I know what I’m doing wrong.

What you are currently doing is not possible. You cannot dynamically reference parent variable names via expressions. Because variable names aren’t strings, they’re references.

You CAN dynamically access children variables, however.

So if you had something like a structure global variable named “textValues”, with a child of “Updater”
You could access it via GlobalVariableString(textValues[ToString(genericTextUpdater.VariableString(TextHere))])

You can read more about it here: Variables [GDevelop wiki]

1 Like

Thanks, Silver-Streak! I’ll try that. It’s kind of like what I was trying to do but by accessing a children variable under the global variable instead of the global variable itself.

1 Like