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)
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)