how can i change text value of a canvas Text in runtime?

im trying to change the value of my Text object while the game is running so text.text = 5.toString()

at the moment i have this code and every time i click on a object it will open the UI but it does not update the numbers when i debug.log the values i do get numbers greater than 0 in the amount array

for(int i = 0; i<texts.Length; i++)
{
if (amount.Length == i)
break;
texts.text = amount*.ToString();*

}

Tnx for trying to help but its already fixed i had multiple array and the text looped true all of them so it only put the text in from the last array