How can I script this UI?

However, if you’re editing the text through a script, you should take a look at this post.