Outputting in-game text like NPC conversations, player instructions, and prompts can be visually enhanced with effects like this:
The following module mimics the effect above and can be used on virtually any
TextButton. To use it in your game:
- Create a new
- Rename the new script TypeWriter.
- Copy the following code into the script.
articles/localization portal additional features#locale-code-reference|locale code(
en) on line 1 to match the game's source language setting in the localization portal.
Key features of this module are:
- Supports localized translations for outputting text in languages which you’ve configured in the
articles/Introduction to Localization on Roblox|localization portal.
- Easy customization options like text output speed and whether there’s a natural delay between word breaks in a sentence.
- Full support for UTF-8 encoding when outputting non-Latin characters as in Chinese or Korean.
To display typewritten text using the module, you’ll need a GUI object which can display text, for instance a
TextLabel. If you’re unfamiliar with text labels and their basic options, see
articles/Intro to GUIs|Intro to GUIs.
- Create a
TextLabel. For testing, a suitable location is within a
- Create a new
LocalScriptas a direct child of the
- Copy the following code into the new
LocalScript. Feel free to change the text within quotes on line 7 to whatever text you desire.
- Playtest your game in Studio and the text should be output letter by letter in the
For convenience, the module contains a configuration function which accepts these parameters:
|delayTime||Delay time, in seconds, between output of each text character.||0.2|
|extraDelayOnSpace||Whether to add a natural delay when a space in the text string is encountered.||true|
To change these settings, simply call the
configure() function of the module, for instance: