Roblox NPC dialogue script
A character who talks: walk up, press the prompt and a speech bubble shows the next line. It works on computers, phones and consoles.
Where it goes
- 1You need a character with a part named Head. In the Avatar tab, Rig Builder makes one.
- 2Hover over the character's Model in the Explorer, press + and choose Script.
- 3Paste this in, change
LINESto what your character says, and press Play.
-- From forja.us/tools/roblox-scripts/npc-dialogue-- Press the prompt to hear this character's next line.local LINES = { "Hello, traveler.", "The old mine is past the bridge.", "Be careful down there.",}local SECONDS_SHOWN = 6local npc = script.Parentlocal head = npc:WaitForChild("Head")local bubble = Instance.new("BillboardGui")bubble.Size = UDim2.fromOffset(260, 80)bubble.StudsOffset = Vector3.new(0, 3, 0)bubble.MaxDistance = 60bubble.Enabled = falsebubble.Parent = headlocal text = Instance.new("TextLabel")text.Size = UDim2.fromScale(1, 1)text.BackgroundColor3 = Color3.new(1, 1, 1)text.TextColor3 = Color3.new(0, 0, 0)text.TextSize = 18text.TextWrapped = truetext.Font = Enum.Font.GothamMediumtext.Parent = bubblelocal prompt = Instance.new("ProximityPrompt")prompt.ActionText = "Talk"prompt.ObjectText = npc.Nameprompt.Parent = headlocal nextLine = 1local shownAt = 0prompt.Triggered:Connect(function() text.Text = LINES[nextLine] bubble.Enabled = true nextLine = nextLine % #LINES + 1 local thisTime = os.clock() shownAt = thisTime task.wait(SECONDS_SHOWN) if shownAt == thisTime then bubble.Enabled = false endend)How it works
- A
ProximityPromptshows the button when a player is close, with the right key or button for their device. - A
BillboardGuikeeps the speech bubble facing the camera above the head. nextLine % #LINES + 1goes back to the first line after the last one.
Make it yours
- Show each player their own lines
- This shows the same bubble to everyone nearby. For one player at a time, or for choices, ask the script generator.
Maps to try it on: fantasy and medieval maps
Start from a finished map, and your scripts have a game to run in.
More free Roblox scripts
Roblox kill brick scriptRoblox leaderboard scriptRoblox save data scriptRoblox sprint scriptRoblox double jump scriptRoblox teleport scriptRoblox obby checkpoint scriptRoblox coin pickup scriptRoblox day and night cycle scriptRoblox game pass scriptRoblox developer product scriptRoblox door scriptRoblox tool giver scriptRoblox round system scriptRoblox background music scriptRoblox speed pad scriptRoblox jump pad scriptRoblox VIP door scriptRoblox daily reward scriptRoblox pet follow scriptRoblox gun scriptRoblox admin commands scriptRoblox tycoon dropper scriptRoblox shop GUI script

