In short
Put the whole line in the TextLabel's Text, set MaxVisibleGraphemes to 0, then raise it by one every short moment with task.wait until every character shows. Count characters with utf8.graphemes so emoji and accented letters count as one. Set MaxVisibleGraphemes = -1 at the end to show everything. To skip, set it to -1 straight away when the player clicks.
- This runs in a LocalScript, because text effects are only drawn on the player's screen.
- Do not build the text with
string.sub. With MaxVisibleGraphemes the layout is worked out for the whole line, so words never jump to the next line halfway through. - Keep rich text off for typed lines. Roblox's own typewriter example removes rich text tags before it types.
Get the script
Typewriter text module with skip
A ModuleScript in ReplicatedStorage that types any TextLabel with frame-rate independent speed, punctuation pauses, an optional blip and a skip function.
-- ModuleScript in ReplicatedStorage named Typewriter. Use it from LocalScripts:
-- Typewriter.play(label, text, options) types the text and returns when it is done or skipped
-- Typewriter.skip(label) shows the rest of the text at once
local SoundService = game:GetService("SoundService")
local DEFAULT_SPEED = 40 -- characters per second
local SOUND_EVERY = 2 -- play the blip every this many letters
-- Extra seconds to wait after these characters, so sentences breathe
local PAUSES: { [string]: number } = {
["."] = 0.3,
["!"] = 0.3,
["?"] = 0.3,
[","] = 0.12,
[":"] = 0.12,
}
export type Options = {
speed: number?, -- characters per second
sound: Sound?, -- a short blip to play while typing
}
type State = { skip: boolean }
-- One entry per label that is typing right now
local running: { [TextLabel]: State } = {}
local Typewriter = {}
function Typewriter.play(label: TextLabel, text: string, options: Options?)
local speed = if options and options.speed then options.speed else DEFAULT_SPEED
local sound = if options then options.sound else nil
-- A new line on the same label replaces the old one: the old loop sees it is no longer current and stops
local state: State = { skip = false }
running[label] = state
-- Split the text into graphemes first, so the loop can look at each one
local characters: { string } = {}
for first, last in utf8.graphemes(text) do
table.insert(characters, string.sub(text, first, last))
end
label.Text = text
label.MaxVisibleGraphemes = 0
local shown = 0
local budget = 0 -- seconds of typing we are allowed to catch up on
while shown < #characters do
if state.skip or running[label] ~= state then
break
end
-- Show as many characters as the time since the last frame allows, so the speed
-- is the same at 30 or 240 frames a second
while shown < #characters and budget >= 0 do
shown += 1
local character = characters[shown]
budget -= 1 / speed + (PAUSES[character] or 0)
if sound and character ~= " " and shown % SOUND_EVERY == 0 then
SoundService:PlayLocalSound(sound)
end
end
label.MaxVisibleGraphemes = shown
budget += task.wait()
end
if running[label] == state then
label.MaxVisibleGraphemes = -1
running[label] = nil
end
end
function Typewriter.skip(label: TextLabel)
local state = running[label]
if state then
state.skip = true
end
end
function Typewriter.isTyping(label: TextLabel): boolean
return running[label] ~= nil
end
return Typewriter
RoCode builds it in the place you have open in Roblox Studio, on Windows or macOS with a desktop browser; on a phone the button sends the prompt and the link to your computer. Free to start, with free credits every day. More Roblox Studio scripts
Where to put it
ReplicatedStorage
Typewriter ModuleScript new
Settings you can change
DEFAULT_SPEEDIn the script- Characters per second when a call does not give its own speed. Default:
40. SOUND_EVERYIn the script- Play the blip sound every this many letters (spaces are skipped). 1 is busy, 3 is calm. Default:
2.
Call it from a LocalScript: Typewriter.play(label, "Hello!") types and waits until done; Typewriter.skip(label) shows the rest at once. Step 3 builds a dialogue box with it.
Type-checked with luau-lsp strict against Roblox's API definitions on 14 November 2026. Not playtested in Studio yet: press Play and watch the Output window before you publish.
Prompt for RoCode
Add a typewriter text effect to my game: a ModuleScript in ReplicatedStorage named Typewriter with play(label, text, options) that uses MaxVisibleGraphemes and utf8.graphemes at 40 characters per second, pauses longer after full stops and commas, plays an optional blip sound every 2 letters with SoundService:PlayLocalSound, and skip(label) to show the rest at once, plus a dialogue box LocalScript where the first click finishes the line and the second shows the next.
On this page
How MaxVisibleGraphemes works
A grapheme is one character as a player sees it. Most are a single letter, but an emoji or an accented letter can be several bytes in the string. MaxVisibleGraphemes is a TextLabel (and TextButton and TextBox) property that says how many graphemes to draw.
| Value | What shows |
|---|---|
-1 | All of the text. This is the default. |
0 | Nothing, although the label still has its Text. |
5 | The first five characters. |
Roblox lays the text out as if every character were visible. That is the big win over cutting the string with string.sub: a long word that will wrap to the next line starts on the next line, instead of appearing at the end of one line and jumping down when it gets too long.
Step 1: The simplest typewriter
- In the Explorer, hover over StarterGui, click + and insert a ScreenGui. Insert a TextLabel inside it, make it wide, and type a sentence into its Text property.
- Hover over the TextLabel and insert a LocalScript named
TypeText. Paste the code below and press Play.
-- LocalScript inside a TextLabel, named TypeText. Types the label's own text once.
local label = script.Parent :: TextLabel
local SECONDS_PER_LETTER = 0.03
label.MaxVisibleGraphemes = 0
local shown = 0
for _ in utf8.graphemes(label.Text) do
shown += 1
label.MaxVisibleGraphemes = shown
task.wait(SECONDS_PER_LETTER)
end
label.MaxVisibleGraphemes = -1 -- show everything, whatever happens to the count
utf8.graphemes walks through the text one visible character at a time, so the loop runs once per character, emoji included. It is enough for a title card. It cannot be skipped, though, and at very small waits it types at most one character per frame, because task.wait never waits less than a frame. The module in Step 2 fixes both.
Step 2: A reusable Typewriter module
- Hover over ReplicatedStorage, click + and insert a ModuleScript. Name it
Typewriter. - Paste the code below.
- Optional: for a typing blip, insert a Sound into ReplicatedStorage named
TypeBlipand set its SoundId to a short click sound from the Toolbox (Audio tab). Step 3 passes it to the module.
-- ModuleScript in ReplicatedStorage named Typewriter. Use it from LocalScripts:
-- Typewriter.play(label, text, options) types the text and returns when it is done or skipped
-- Typewriter.skip(label) shows the rest of the text at once
local SoundService = game:GetService("SoundService")
local DEFAULT_SPEED = 40 -- characters per second
local SOUND_EVERY = 2 -- play the blip every this many letters
-- Extra seconds to wait after these characters, so sentences breathe
local PAUSES: { [string]: number } = {
["."] = 0.3,
["!"] = 0.3,
["?"] = 0.3,
[","] = 0.12,
[":"] = 0.12,
}
export type Options = {
speed: number?, -- characters per second
sound: Sound?, -- a short blip to play while typing
}
type State = { skip: boolean }
-- One entry per label that is typing right now
local running: { [TextLabel]: State } = {}
local Typewriter = {}
function Typewriter.play(label: TextLabel, text: string, options: Options?)
local speed = if options and options.speed then options.speed else DEFAULT_SPEED
local sound = if options then options.sound else nil
-- A new line on the same label replaces the old one: the old loop sees it is no longer current and stops
local state: State = { skip = false }
running[label] = state
-- Split the text into graphemes first, so the loop can look at each one
local characters: { string } = {}
for first, last in utf8.graphemes(text) do
table.insert(characters, string.sub(text, first, last))
end
label.Text = text
label.MaxVisibleGraphemes = 0
local shown = 0
local budget = 0 -- seconds of typing we are allowed to catch up on
while shown < #characters do
if state.skip or running[label] ~= state then
break
end
-- Show as many characters as the time since the last frame allows, so the speed
-- is the same at 30 or 240 frames a second
while shown < #characters and budget >= 0 do
shown += 1
local character = characters[shown]
budget -= 1 / speed + (PAUSES[character] or 0)
if sound and character ~= " " and shown % SOUND_EVERY == 0 then
SoundService:PlayLocalSound(sound)
end
end
label.MaxVisibleGraphemes = shown
budget += task.wait()
end
if running[label] == state then
label.MaxVisibleGraphemes = -1
running[label] = nil
end
end
function Typewriter.skip(label: TextLabel)
local state = running[label]
if state then
state.skip = true
end
end
function Typewriter.isTyping(label: TextLabel): boolean
return running[label] ~= nil
end
return Typewriter
The budget is what makes the speed steady. Each frame, task.wait() returns how long the frame took and adds it to the budget, and the inner loop shows characters until the budget runs out. At 40 characters a second and 60 frames a second, most frames show one character and some show none. On a slow phone at 20 frames a second, each frame shows two, so the line still takes the same time.
A full stop costs its normal 1/40 of a second plus 0.3 seconds from PAUSES, which gives the little stop between sentences that makes dialogue feel spoken. SoundService:PlayLocalSound plays a copy of the blip only for this player, so quick blips can overlap without cutting each other off.
Step 3: A dialogue box with click to skip
Players read at different speeds, so good dialogue lets them skip. The usual rule: while a line is typing, a click shows the rest of it; when the line is finished, a click goes to the next one. This module builds the box itself and gives you one function, DialogueBox.show(speaker, lines).
- Insert a second ModuleScript into ReplicatedStorage named
DialogueBox. - Paste the code below. It needs the Typewriter module from Step 2 next to it.
-- ModuleScript in ReplicatedStorage named DialogueBox. Use it from LocalScripts:
-- DialogueBox.show("Guide", { "Hi!", "Welcome to the island." }) returns when the player closes it
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
type TypewriterModule = {
play: (label: TextLabel, text: string, options: { speed: number?, sound: Sound? }?) -> (),
skip: (label: TextLabel) -> (),
isTyping: (label: TextLabel) -> boolean,
}
local Typewriter = require(ReplicatedStorage:WaitForChild("Typewriter")) :: TypewriterModule
local TYPE_SPEED = 40 -- characters per second
local found = ReplicatedStorage:FindFirstChild("TypeBlip")
local blip: Sound? = if found and found:IsA("Sound") then found else nil
-- Build the box once, the first time this module is required
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "DialogueBox"
screenGui.ResetOnSpawn = false
screenGui.DisplayOrder = 5
screenGui.Parent = Players.LocalPlayer:WaitForChild("PlayerGui")
-- The whole box is one TextButton, so a click or tap anywhere on it counts
local box = Instance.new("TextButton")
box.Name = "Box"
box.Text = ""
box.AutoButtonColor = false
box.AnchorPoint = Vector2.new(0.5, 1)
box.Position = UDim2.new(0.5, 0, 1, -24)
box.Size = UDim2.new(0.9, 0, 0, 150)
box.BackgroundColor3 = Color3.fromRGB(20, 18, 28)
box.BackgroundTransparency = 0.1
box.Visible = false
box.Parent = screenGui
local sizeLimit = Instance.new("UISizeConstraint")
sizeLimit.MaxSize = Vector2.new(720, 150)
sizeLimit.Parent = box
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 12)
corner.Parent = box
local nameLabel = Instance.new("TextLabel")
nameLabel.BackgroundTransparency = 1
nameLabel.Position = UDim2.fromOffset(20, 12)
nameLabel.Size = UDim2.new(1, -40, 0, 26)
nameLabel.FontFace = Font.fromEnum(Enum.Font.BuilderSansBold)
nameLabel.TextSize = 22
nameLabel.TextColor3 = Color3.fromRGB(255, 205, 90)
nameLabel.TextXAlignment = Enum.TextXAlignment.Left
nameLabel.Parent = box
local body = Instance.new("TextLabel")
body.BackgroundTransparency = 1
body.Position = UDim2.fromOffset(20, 44)
body.Size = UDim2.new(1, -40, 1, -76)
body.FontFace = Font.fromEnum(Enum.Font.BuilderSans)
body.TextSize = 20
body.TextColor3 = Color3.new(1, 1, 1)
body.TextWrapped = true
body.TextXAlignment = Enum.TextXAlignment.Left
body.TextYAlignment = Enum.TextYAlignment.Top
body.Parent = box
local hint = Instance.new("TextLabel")
hint.BackgroundTransparency = 1
hint.AnchorPoint = Vector2.new(1, 1)
hint.Position = UDim2.new(1, -16, 1, -8)
hint.Size = UDim2.fromOffset(200, 20)
hint.FontFace = Font.fromEnum(Enum.Font.BuilderSans)
hint.TextSize = 14
hint.TextColor3 = Color3.fromRGB(170, 165, 190)
hint.TextXAlignment = Enum.TextXAlignment.Right
hint.Text = "Click to continue"
hint.Parent = box
-- Clicks, taps, Enter and the gamepad X button all mean "next"
local advance = Instance.new("BindableEvent")
box.Activated:Connect(function()
advance:Fire()
end)
UserInputService.InputBegan:Connect(function(input: InputObject, processedByUI: boolean)
if processedByUI or not box.Visible then
return
end
if input.KeyCode == Enum.KeyCode.Return or input.KeyCode == Enum.KeyCode.ButtonX then
advance:Fire()
end
end)
local open = false
local DialogueBox = {}
function DialogueBox.show(speaker: string, lines: { string })
if open then
return -- one conversation at a time
end
open = true
nameLabel.Text = speaker
box.Visible = true
for _, line in lines do
hint.Visible = false
task.spawn(function()
Typewriter.play(body, line, { speed = TYPE_SPEED, sound = blip })
hint.Visible = true
end)
-- First press: if the line is still typing, finish it and wait for a second press
advance.Event:Wait()
if Typewriter.isTyping(body) then
Typewriter.skip(body)
advance.Event:Wait()
end
end
box.Visible = false
open = false
end
return DialogueBox
The heart of it is the end of show. The line types in its own thread (task.spawn), while show waits for the player. On the first press it asks the Typewriter whether the line is still typing. If it is, it skips and waits for one more press; if it is not, the loop moves straight to the next line. The "Click to continue" hint only appears once a line is complete, so players know when a click will move on.
X is used on a gamepad instead of A, because A also makes the character jump. Enter is used on a keyboard for the same reason: Space jumps.
Step 4: Start a conversation from a prompt
Now make an NPC or a sign start the dialogue. A ProximityPrompt fires Triggered on the client of the player who used it, so a LocalScript can open the box straight away with no RemoteEvent.
- Make a Part in the Workspace named
Signand insert a ProximityPrompt into it. Set its ActionText toRead. - In StarterPlayer, hover over StarterPlayerScripts and insert a LocalScript named
SignDialogue. Paste the code below.
-- LocalScript in StarterPlayerScripts named SignDialogue.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
type DialogueBoxModule = {
show: (speaker: string, lines: { string }) -> (),
}
local DialogueBox = require(ReplicatedStorage:WaitForChild("DialogueBox")) :: DialogueBoxModule
local sign = workspace:WaitForChild("Sign")
local prompt = sign:WaitForChild("ProximityPrompt") :: ProximityPrompt
local LINES = {
"Welcome, traveller. This island has been quiet for a hundred years.",
"Something woke up in the caves last night...",
"If you go in, take a torch. And do not touch the glowing crystals!",
}
prompt.Triggered:Connect(function()
prompt.Enabled = false -- hide the prompt while the box is open
DialogueBox.show("Old Sign", LINES)
prompt.Enabled = true
end)
Setting prompt.Enabled from a LocalScript only hides the prompt for this player, so others can still read the sign at the same time. If the conversation should give a reward or a quest, the server has to decide that: see the NPC dialogue guide, which adds choices and server-checked outcomes, and the ProximityPrompt guide for prompt settings.
Step 5: Test it
- Press Play, walk to the Sign and press E. The box opens and the first line types out, with a short stop after each full stop.
- Click while it is typing: the rest of the line appears at once. Click again: the next line starts.
- Press Enter instead of clicking to check the keyboard path, and use the device emulator (Test tab, Device) to try a phone screen: tapping the box works the same way.
- After the last line the box closes and the prompt comes back.
- If you added a TypeBlip sound and hear nothing, check the sound's Volume and that its SoundId loads (the Output window warns when it cannot).
Common errors and fixes
If the text does not type, check the Output window first.
All the text appears at once
The script is a Script instead of a LocalScript, or MaxVisibleGraphemes is set back to -1 too early. Text effects belong in LocalScripts.
Rich text tags show up as letters while typing
Typing counts every character you give it, tags included. Turn RichText off for typed lines, or remove the tags first as Roblox's own typewriter example does with gsub("<[^<>]->", "").
Clicking the box does nothing
Another GUI is on top of it. Raise the DialogueBox ScreenGui's DisplayOrder, or check that the box is a TextButton and Active is ticked.
Requested module experienced an error while loading
The DialogueBox module errored while it built the GUI, often because Typewriter is missing from ReplicatedStorage or named differently. See Requested module experienced an error while loading.
Infinite yield possible on Sign
The part is not named exactly Sign, is not directly in the Workspace, or has no ProximityPrompt. See Infinite yield possible.
Build it with RoCode
If you would rather not set this up by hand, RoCode can build it in the place you have open. RoCode is an independent AI agent for Roblox Studio, not made by Roblox: you describe the change in a web chat, and its Studio plugin creates the parts and scripts in your Explorer, so there is no code to paste.
Add a dialogue box with typewriter text to my game: the old fisherman NPC talks when you press E, letters type at 40 a second with a blip, the first click finishes the line and the second shows the next.
- Can read your place first to find the NPC you mean, then adds the prompt and the scripts
- Writes the scripts with Create Script and is told to compile-check each one with Check Script
- Sets an undo point before and after each batch of changes, so Ctrl+Z steps back one batch at a time
Questions
How do I make a typewriter effect in Roblox Studio?
Set the TextLabel's Text to the whole line, set MaxVisibleGraphemes to 0, and raise it by one in a loop over utf8.graphemes(text) with a short task.wait. Step 1 is the five-line version.
What is MaxVisibleGraphemes in Roblox?
A property of TextLabel, TextButton and TextBox that limits how many characters are drawn. -1 shows all of them. Roblox made it for typewriter effects.
How do I skip typewriter text when the player clicks?
Keep a skip flag for the label, set it from the click, and have the typing loop stop and set MaxVisibleGraphemes = -1 when it sees the flag. The Typewriter module's skip function does this.
Why use MaxVisibleGraphemes instead of string.sub?
With string.sub the label lays out a growing string, so words jump to the next line as they get longer. MaxVisibleGraphemes lays out the full line from the start. It also counts emoji as one character.
How do I add a typing sound?
Every few characters, play a short Sound with SoundService:PlayLocalSound(sound). It plays a copy only for that player, so blips can overlap. Skip spaces so the rhythm follows the words.
How do I make text type at the same speed on every device?
Use the time each frame took (the value task.wait() returns) to decide how many characters to show, as the Typewriter module does, instead of one character per wait.
Sources and further reading
- Roblox Creator Docs: TextLabel. MaxVisibleGraphemes
- Roblox Creator Docs: UI animation, typewriter effect. Roblox's own example with utf8.graphemes
- Roblox Creator Docs: SoundService. PlayLocalSound
- Roblox Creator Docs: ProximityPrompt. Triggered and Enabled
How the code was checked: every script on this page passes Luau's strict type checker against Roblox's API definitions (luau-lsp, 14 November 2026). A type check catches misspelt APIs and wrong types, not game logic, so playtest in Studio before you publish.