Update: I think the problem is solved now, than you! I used the scripts in a clean project and it worked perfectly fine, so it is not the problem with the script.
It turns out that a playmaker component is interfering with the text component, I deleted that playmaker component and it worked.
