How do I center text on a rich text label?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cookieKing_

I’m making a clicker game and I added a money counter that’s a RichTextLabel, but I want the text to be centered.

:bust_in_silhouette: Reply From: jgodfrey

You can control the text alignment via bbcode tags. So…

  • Check Bbcode Enabled in the control’s inspector
  • Add your text, wrapped in [center]...[\center] tags. Something like:

[center]This is my centered text.[/center]

When I do that, it says:
Expected end of statement after expression, found “Identifier” instead.

This is the code for the text label:

$Money.text = [center]str([/center]

cookieKing_ | 2023-04-16 22:25

Try something like this:

$Money.text = "[center]%s[/center]" %

jgodfrey | 2023-04-16 23:36

It worked, thanks!

cookieKing_ | 2023-04-16 23:42

1 Like