What I’m trying to do is making a modified version of a NPC Dialog System in Toolbox, so that when you interact with a NPC, you get different dialogs. Now, I know where I went wrong, but I don’t know how to fix it (haven’t coded in a long time)
SCRIPT1 (local script):
function inDialog(ChosenPath, Dialog, Number, Enabled)
if Enabled then
if Dialog[ChosenPath] then
print(ChosenPath)
if ChosenPath[Number] then
print(ChosenPath[Number])
typeWrite(ChosenPath[Number])
end
end
else
print("Conversation Ended.")
end
end
function inDialog(ChosenPath, Dialog, Number, Enabled)
if Enabled then
local ChosenPathDialog = Dialog[ChosenPath]
if ChosenPathDialog then
local ChosenDialog= ChosenPathDialog[Number]
if ChosenDialog then
print(ChosenDialog)
typeWrite(ChosenDialog)
end
end
else
print("Conversation Ended.")
end
end
-- i also assume you got a typewrite function somewhere
& is this how you call the function?
inDialog(ChosenPath, NPCModule["Test"], Number, Enabled)
-- assuming u got number & enabled somewhere idk & the module required of course
I’ll try out that method. If it works, I’ll reply.
And for this, I basically have a math.random as the ChosenPath to basically randomize the chances, Dialog is basically the NPC’s dialogs, Number is the 1st - 3rd message, Enabled is basically there to turn on or off the inDialog
So it didn’t work. I honestly don’t know what the problem is to be honest. I know where I went wrong, I just can’t pinpoint it.
Here’s the text activation if you want to figure out what in the world I did wrong
text.Activated:Connect(function()
if not debounce then
debounce = true
NPC_Amount += 1
task.wait(1)
debounce = false
end
if typeWriting then
return
end
local NPCNAME = npcModule[NPC_Value.Value]
inDialog(Random_Dialog, NPCNAME, NPC_Amount, true)
end)