Documentation for the DGD script version 1.0
The Direct Game Dialog (DGD) is a versatile dialogue system for Roblox games, designed to enhance player interaction and storytelling. With DGD, you can create immersive conversations between players and NPCs, featuring sounds, multiple characters, proximity triggers, dialogue branching, and more.
This documentation provides step-by-step guidance on using DGD, from basic setup to advanced features. Each section includes beginner and expert instructions to cater to all skill levels.
You’ll need the following to use and customize DGD:
Be careful when modifying scripts. Incorrect changes may break functionality. Test thoroughly in Roblox Studio.
To start using DGD in your Roblox game, follow these steps:
ServerScriptService.ReplicatedStorage:
DialogueEvent under ReplicatedStorage.RemoteEvents.GuiEventsToggleDialogueEvent under ReplicatedStorage.RemoteEvents.ToggleEventsStarterGui named DialogueGui with:
ImageLabel for character imageTextLabel for nameTextLabel for dialogue textLocalScript in StarterPlayerScripts to handle dialogue display:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DialogueEvent = ReplicatedStorage.RemoteEvents.GuiEvents.DialogueEvent
local playerGui = game.Players.LocalPlayer.PlayerGui
local dialogueGui = playerGui:WaitForChild("DialogueGui")
local imageLabel = dialogueGui.Frame.ImageLabel
local nameLabel = dialogueGui.Frame.NameLabel
local textLabel = dialogueGui.Frame.TextLabel
DialogueEvent.OnClientEvent:Connect(function(image, name, text)
imageLabel.Image = image
nameLabel.Text = name
textLabel.Text = text
dialogueGui.Enabled = true
end)
DGD uses dialogue sequences defined as Lua tables. Each line includes a speaker, text, and optional delay.
Create and play a basic dialogue sequence:
local sequence = {
{speaker = "NPC", text = "Hello, adventurer!", delay = 3},
{speaker = "Player", text = "Hi there!", delay = 2},
{speaker = "NPC", text = "Welcome to the game.", delay = 3}
}
local DialogueEvent = game.ReplicatedStorage.RemoteEvents.GuiEvents.DialogueEvent
function PlayDialogue(sequence)
for _, line in ipairs(sequence) do
local image, name = "rbxassetid://9876543210", "Guard"
if line.speaker == "Player" then
image, name = "rbxassetid://1234567890", game.Players.LocalPlayer.Name
end
DialogueEvent:FireAllClients(image, name, line.text)
wait(line.delay or 3)
end
end
PlayDialogue(sequence)
Tip: Adjust delays to control pacing—short for quick chats, long for drama.
Play a sound when a dialogue line is displayed:
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://1234567890"
sound.Parent = game.Workspace
function PlayDialogue(sequence)
for _, line in ipairs(sequence) do
if line.text == "Hello, adventurer!" then
sound:Play()
end
DialogueEvent:FireAllClients("rbxassetid://9876543210", "Guard", line.text)
wait(line.delay or 3)
end
end
Create a module to manage multiple sounds:
-- SoundManager.lua in ServerScriptService
local SoundManager = {}
function SoundManager:PlaySound(id)
local sound = Instance.new("Sound")
sound.SoundId = id
sound.Parent = game.Workspace
sound:Play()
sound.Ended:Connect(function() sound:Destroy() end)
end
return SoundManager
-- In your main script
local SoundManager = require(game.ServerScriptService.SoundManager)
function PlayDialogue(sequence)
for _, line in ipairs(sequence) do
if line.text == "Welcome to the game." then
SoundManager:PlaySound("rbxassetid://9876543210")
end
DialogueEvent:FireAllClients("rbxassetid://9876543210", "Guard", line.text)
wait(line.delay or 3)
end
end
Define a new NPC with a dialogue sequence:
local NPC = {
Image = "rbxassetid://9876543210",
Name = "Guard",
Dialogue = {
{speaker = "NPC", text = "Halt! Who goes there?", delay = 3},
{speaker = "Player", text = "Just a traveler.", delay = 2}
}
}
PlayDialogue(NPC.Dialogue)
Generate dialogue based on game state:
local function GetDialogue(player)
if player.leaderstats.Level.Value >= 10 then
return {speaker = "NPC", text = "You're a seasoned adventurer!", delay = 3}
else
return {speaker = "NPC", text = "You’re new here, aren’t you?", delay = 3}
end
end
local NPC = {
Image = "rbxassetid://9876543210",
Name = "Guard",
Dialogue = {GetDialogue(game.Players:GetPlayers()[1])}
}
PlayDialogue(NPC.Dialogue)
Use a proximity prompt to start dialogue:
local prompt = game.Workspace.NPCPrompt.ProximityPrompt
prompt.Triggered:Connect(function(player)
PlayDialogue(NPC.Dialogue)
end)
Add conditions for specific players or items:
local guardDialogue = {{speaker = "NPC", text = "Welcome, guard!", delay = 3}}
local defaultDialogue = {{speaker = "NPC", text = "State your business.", delay = 3}}
prompt.Triggered:Connect(function(player)
if player.Team == game.Teams.Guards then
PlayDialogue(guardDialogue)
elseif player.Backpack:FindFirstChild("KeyItem") then
PlayDialogue({{speaker = "NPC", text = "You have the key!", delay = 3}})
else
PlayDialogue(defaultDialogue)
end
end)
Offer basic player choices:
local choices = {
{text = "Yes", response = {speaker = "NPC", text = "Great! Let’s go.", delay = 3}},
{text = "No", response = {speaker = "NPC", text = "Maybe later.", delay = 3}}
}
-- Add UI buttons and connect to PlayDialogue(choices[1].response) or choices[2].response
Create complex branching dialogue:
local dialogueTree = {
start = {
text = "Join the quest?",
choices = {
{text = "Yes", next = "questAccepted"},
{text = "No", next = "questDeclined"}
}
},
questAccepted = {
text = "Here’s your task.",
choices = {
{text = "Accept", next = "taskGiven"},
{text = "Back", next = "start"}
}
},
questDeclined = {
text = "Come back anytime."
},
taskGiven = {
text = "Good luck!"
}
}
-- Implement a function to navigate the tree and display choices
Customize DGD to fit your game:
DialogueGui for custom fonts, colors, or animations.
local part = game.Workspace.ClickPart
part.ClickDetector.MouseClick:Connect(function(player)
PlayDialogue(sequence)
end)
if player.leaderstats.Quests.Value > 0 then
PlayDialogue(questDialogue)
end
Contact us at support@example.com or visit [support forum link].
Version 1.0 - [Date]
- Initial release with basic dialogue, sounds, characters, and proximity prompts.
Released under the MIT License.