Change text to a object variable

Hi.
Lets say I have two objects “NewText” and “NewSprite”.

The “NewSprite” has variable:

At the beginning of the scene, I want to change the text of the “NewText” to the “color” variable of the “NewSprite”. I tried this:

but it doesn’t work as I expected. The “NewText” give me the output “0” instead of “white”. Why is that?

The expression-editor generates the wrong code (or the code is not processed correctly.)

Workaround: Replace ToString(NewSprite.Variable(id)) with NewSprite.VariableString(id).
I had the same problem, it would be great if someone could fix it.
https://forum.gdevelop.io/t/solved-read-instance-variable-string/40993

1 Like

Thx bro!
The “object.VariableString()” works flawlessly. :slight_smile:

It’s already been fixed, and should be included in the next release: String and number object variables both have same name · Issue #4223 · 4ian/GDevelop · GitHub

5 Likes