I'm currently coding a quest system. Everything was working fine until I started referencing my ModuleScript. No error appears in my output window until I interact with the NPC named "Maddie". This is the error that appears: 00:05:52.993 - Workspace.Maddie.QuestNPC:33: attempt to call field 'dialog' (a table value). When touching this NPC, you are supposed to see a GUI with the text from the ModuleScript... I don't see what I did wrong here.
Code for the script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local QuestLibraries = ReplicatedStorage:FindFirstChild("QuestLibraries")
--libraries--
local Dialogs = require(QuestLibraries:FindFirstChild("Dialogs"))
local Quests = require(QuestLibraries:FindFirstChild("Quests"))
-- Variables --
local QuestGUI = ReplicatedStorage:FindFirstChild("QuestDialog", true)
local Quest = script.Configurations.Quest.Value
local Enabled = script.Configurations.QuestEnabled.Value
script.Parent.Torso.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") ~= nil then
local Player = game.Players:FindFirstChild(part.Parent.Name)
local PlayerGui = Player:FindFirstChild("PlayerGui")
if PlayerGui:FindFirstChild("QuestDialog") == nil then
---- GUI Parts ----
local GUI = QuestGUI:Clone()
local Main = GUI
local GUI_Name = Main:FindFirstChild("Name", true)
local Decline_Btn = Main:FindFirstChild("Decline", true)
local Accept_Btn = Main:FindFirstChild("Accept", true)
local NPC_Dialog = Main:FindFirstChild("DialogBox", true)
---- Quest/Dialog Tables ----
local Dialog_Data = Dialogs.dialog(Quest)
---- Set Defaults ----
GUI_Name.Text = " " .. script.Parent.Name
Decline_Btn.Text = Dialog_Data("EXIT")
GUI.Parent = PlayerGui -- Put GUI into Player GUI
---- Get number of dialogs ----
local num_of_dialogs = 0
for key, value in pairs(Dialog_Data) do
if key ~= "EXIT" then
num_of_dialogs = num_of_dialogs + 0.5
end
end
---- Go through dialog ----
local dialog_num = 1
NPC_Dialog.Text = Dialog_Data("NPC" .. dialog_num)
Accept_Btn.Text = Dialog_Data("RES" .. dialog_num)
Accept_Btn.MouseButton1Click:Connect(function()
if dialog_num ~= num_of_dialogs then
dialog_num = dialog_num + 1
NPC_Dialog.Text = Dialog_Data("NPC" .. dialog_num)
Accept_Btn.Text = Dialog_Data("RES" .. dialog_num)
else
GUI:Destroy()
end
end)
end
end
end)
ModuleScript:
local module = {}
module.dialog = {
["QUEST01"] = {
["NPC1"] = "Hey buddy... I need your help.";
["RES1"] = "What is it?";
["NPC2"] = "I need you to go kill some rocks.";
["RES2"] = "Sure.. I'll go kill.... wait... you said rocks?";
["NPC3"] = "Yeah. I need you to kill rocks.";
["RES3"] = "You can't kill a rock if it's not even living. But sure, consider it done.";
["EXIT"] = "I'm not helping you, loser."
}
}
return module
Can someone tell me how I can fix this and why you did this so I can improve my scripting skills? Oh, and I replaced the StartQuest scripts with GUI:Destroy().

3 comments
Maybe replace the parentheses on line 33 with square brackets. You're indexing an dictionary like you would a function.
Upon doing that, I created an error on 38 for the same thing. So I did the same thing on every line that happened for and now it's fixed. Thank you, sir. One more question, why you would use a square bracket instead of a parenthesis?
You can only index a table with a square bracket. Parentheses are typically used for calling functions.