Change textColor from DB

I’m having some trouble changing textColor from a DB?

My DB is sending over
“colorChange”: “0.1,0.3,0.5,1”

I know the data coming from DB displays as 0.1,0,3,0.5,1 … but from some reason it’s not working.

When I enter the numbers in manually it works:
Button_1aText.textColor([0.1,0.3,0.5,1]);

When I use the this code the text goes white
Button_1aText.textColor([DBData.colorChange]);

Any thoughts @stevesanerd or @George

Hi @chatflicker,

I’m assuming DBData.colorChange is a string, you need to convert that into an array as that’s what the function expects.

What it expects:
[0.1, 0.3, 0.5, 1] // array containing 4 number elements.
What you’ve supplied it:
[“0.1,0.3,0.5,1”] // Array containing a single string element.

Looks like your values are seperated by commas, so you could split the string by “,”.
"0.1,0.3,0.5,1".split(',') would give us an array ["0.1", "0.3", "0.5", "1"]

The same applies to colorChange. This should work:
Button_1aText.textColor(DBData.colorChange.split(','));

1 Like