Need help for NPC dialogue system

I’m trying to make a NPC dialogue system but I want to make the dialogue typing until the end. I tried other things but they didn’t work. Here’s the Dialogue script (type: ModuleScript):

local dialogueTest = {
	["DummyDia0"] = {
		["Name"] = "Dummy",
		["Dialogue"] = {
			["first"] = "sup",
			["second"] = "ur bored and play roblox, dont ya?",
		}
	}
}

return dialogueTest

The local script that inside the gui frame:

local dialogue = require(script.Dialogue)
local DummyPP = workspace.R6.Torso.heyWassup

DummyPP.Triggered:Connect(function()
	script.Parent.daName.Text = dialogue.DummyDia0.Name
	script.Parent.Talk.Text = dialogue.DummyDia0.Dialogue.first --this is an example dialogue
end)

And some screenshots from explorer:
Ekran görüntüsü 2024-04-21 185908
Ekran görüntüsü 2024-04-21 185923
Ekran görüntüsü 2024-04-21 185934

Can anyone help please?

2 Likes

Try this:

Client:

local dialogue = require(script.ModuleScript) -- change this to your script
local DummyPP = workspace.T.ProximityPrompt  -- change this to where your dialogue starts
local TalkLabel = script.Parent.Talk

local function TypeDialogue(dialogueText) -- just a function for better dialogue
	local currentIndex = 0
	local function TypeNextCharacter()
		currentIndex = currentIndex + 1
		TalkLabel.Text = string.sub(dialogueText, 1, currentIndex)
		if currentIndex < #dialogueText then
			wait(0.05) -- Adjust the delay between characters as needed
			TypeNextCharacter()
		end
	end
	TypeNextCharacter()
end

DummyPP.Triggered:Connect(function() -- example
	script.Parent.daName.Text = dialogue.DummyDia0.Name
	TypeDialogue(dialogue.DummyDia0.Dialogue.first)
end)

Screenshot:
Screenshot 2024-04-21 183159

Hope this helped

3 Likes

It worked! Thanks for helping :smiley:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.