PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.

Animating Text

Animating Text

5 min

Game UI can be significantly enhanced by outputting in-game text like NPC conversations, player instructions, and prompts with animated effects.

Animation Module

Animation effects can be bundled into a ModuleScript for convenient access from multiple text objects in your game.

  1. Create a new ModuleScript within ReplicatedStorage.
  2. Rename the new script AnimateUI.
  1. Paste the following code into the script:

Typewriter Effect

The “typewriter” effect is ideal for TextLabel|TextLabels that tell a story, output NPC conversations, etc.

  1. Create a TextLabel (for testing, a suitable location is within a ScreenGui parented to StarterGui).
  2. Insert a new LocalScript as a direct child of the label and paste in the following code. Note that each message is output by calling AnimateUI.typeWrite with parameters for the parent object, the string to output, and the delay between characters.

The module’s AnimateUI.typeWrite function works as follows:

  1. Initial setup occurs, including declaration of the displayText variable equal to the text parameter, and text translation if a Translator has been loaded by the module’s AnimateUI.loadTranslator function.
  1. If the text uses articles/gui rich text|rich text tags, XML/HTML line breaks and other formatting characters are replaced, then the translated/modified text is set on the parent.
  1. The displayText string is iterated over by UTF-8 grapheme clusters, increasing the TextLabel/MaxVisibleGraphemes property with a wait of delayBetweenChars between characters.

Tags:
  • text
  • animate
  • localization