(Solved) Can't get a character from a text

I don’t know if I’m doing it correctly, but the variable “p1” always returns 0.

Thank you for any help!

Not sure what you’re trying to do, but right now “VariableChildCount” is just going to return a number. You’re also saying to only return the fourth character in that number (StrAt starts with 0, so by saying StrAt(Mything,3) you want to return the fourth character, and it is EXTREMELY unlikely you have 1000 child variables).

What is your actual goal?

I want to get the first letter of my array “word” choosen by my random. I set it to 0 and then changed to 1,2,3 and so on, to see if it would return a letter.
Does it return only numbers?
I have only 10 children.
I used the Text Manipulation and get a character from a text.

In your last event, you are using the expression “VariableChildCount” which will only ever return numbers, period. Because it exists to say “How many children exist of this variable”

If “Words” is a structure variable, it sounds like you want to change from ToString(VariableChildCount) to VariableString(Words[ToString(Variable(random))]).

If “Words” is an array, it sounds like you want to switch to VariableString(Words[Variable(Random)]).

Gonna try it! Many thanks for while.

Changed to this. But still nothing.

Is words an Array variable or a Structure variable?

Also note: By doing this event above the rest of your events, that child variable no longer exists.

Words is a Scene Array Variable.
I changed the action to store it before I remove the child but it doesn’t work either.

Then overall your expression formatting is correct, but you still need to remove

Or move it to be the very last action.

Even deleting the remove index action it doesn’t work.

This also needs to be VariableString, otherwise you’re trying to get p1 as a number.

How does this code you told me knows wich letter I want to get from the text?

You replaced too much of your expression, but right now that’s irrelevant. Your issue is you need to make sure you can get the variable string to return first, then you can wrap it in the StrAt(YourExpression,3).

Got it. Many many thanks!!! Working great!

1 Like