How to clear a RichTextLabel with script?

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


Got a scrolling RichTextLabel displaying diferent texts from diferent tiles, but i’d like it to be clear when entering new tiles, instead of adding texts to texts.
What should i write please?

:bust_in_silhouette: Reply From: Zylann

To reset the text of a RichTextLabel to be something else, you can assign the text property:

rich_text_label.text = "new text" 

or if you use bbcode, use the bbcode_text property:

rich_text_label.bbcode_text = "new text"

Or "" if you want it to be empty, which does the same as clear().


Syl | 2020-02-24 23:58

:bust_in_silhouette: Reply From: jgodfrey

You want the clear function. To use it, you’ll need access to the RichTextLabel node. Assuming it has the default name and is a child of the scene root node, this will work: