Direct Game Dialog (DGD)

Documentation for the DGD script version 1.0


Introduction


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.

Requirements

You’ll need the following to use and customize DGD:

  1. Roblox Studio
  2. Basic knowledge of Lua (Luau) scripting
  3. A Roblox game project

Be careful when modifying scripts. Incorrect changes may break functionality. Test thoroughly in Roblox Studio.

Getting Started

To start using DGD in your Roblox game, follow these steps:

  1. Download the DGD script from [insert link or Roblox library].
  2. Place the script in ServerScriptService.
  3. Create RemoteEvents in ReplicatedStorage:
    • DialogueEvent under ReplicatedStorage.RemoteEvents.GuiEvents
    • (Optional) ToggleDialogueEvent under ReplicatedStorage.RemoteEvents.ToggleEvents
  4. Set up a UI in StarterGui named DialogueGui with:
    • ImageLabel for character image
    • TextLabel for name
    • TextLabel for dialogue text
  5. Add a LocalScript 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)
                                            

Basic Usage

DGD uses dialogue sequences defined as Lua tables. Each line includes a speaker, text, and optional delay.

Beginner: Simple Dialogue

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.

Advanced Features

Sounds

Beginner: Adding Sound Effects

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
                                
Expert: Sound Manager

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
                                

New Characters

Beginner: Adding an NPC

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)
                                
Expert: Dynamic Characters

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)
                                

Proximity Prompts

Beginner: Basic Trigger

Use a proximity prompt to start dialogue:

local prompt = game.Workspace.NPCPrompt.ProximityPrompt
prompt.Triggered:Connect(function(player)
    PlayDialogue(NPC.Dialogue)
end)
                                
Expert: Conditional Prompts

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)
                                

Dialogue Branching

Beginner: Simple Choices

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
                                
Expert: Dialogue Trees

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
                                

Customization

Customize DGD to fit your game:

  • UI Design: Edit DialogueGui for custom fonts, colors, or animations.
  • Triggers: Use clicks instead of prompts:
    local part = game.Workspace.ClickPart
    part.ClickDetector.MouseClick:Connect(function(player)
        PlayDialogue(sequence)
    end)
                                            
  • Integration: Link to quests or inventory:
    if player.leaderstats.Quests.Value > 0 then
        PlayDialogue(questDialogue)
    end
                                            

Troubleshooting

  • Dialogue not showing: Check RemoteEvent setup and client script.
  • Sounds not playing: Verify SoundId and parent.
  • Prompts not triggering: Ensure prompt is enabled and in range.

Support

Contact us at support@example.com or visit [support forum link].

Changelog

Version 1.0 - [Date]
- Initial release with basic dialogue, sounds, characters, and proximity prompts.
                                

License

Released under the MIT License.