I am making a script for a quest system for my RPG, and I came across the annoying error that I always get.
19:46:16.909 - Workspace.Villager.NPC.QuestScript:28: attempt to index local 'Dialog_Data' (a nil value) 19:46:16.910 - Stack Begin 19:46:16.910 - Script 'Workspace.Villager.NPC.QuestScript', Line 28 19:46:16.910 - Stack End
Nil value.
I have no idea how to fix it and I have no real clue about what it is.
This is the small chunk of code that is the biggest problem:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local QuestLibraries = ReplicatedStorage:FindFirstChild("QuestLibraries") local Dialogs = require(QuestLibraries:FindFirstChild("Dialogs")) local Quest = require(QuestLibraries:FindFirstChild("Quests")) local QuestGUI = ReplicatedStorage:FindFirstChild("QuestDialog", true) local Quest1 = script:FindFirstChild("Configurations") --These are the settings and such local Quest = Quest1.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 local GUI = QuestGUI:clone() local Main = GUI.Frame local Decline_BTN = Main:FindFirstChild("No") local Dialog_Data = Dialogs.dialog[Quest.Value] local Accept_BTN = Main:FindFirstChild("Yes") local NPC_Dialog = Main:FindFirstChild("MainText") Decline_BTN.Text = Dialog_Data["EXIT"] --This is the error
Any help recieved is great. Thanks!
Let's dissect the output first.
19:46:16.909 - Workspace.Villager.NPC.QuestScript:28: attempt to index local 'Dialog_Data' (a nil value) Not enough added to function
19:46:16.910 - Stack Begin 19:46:16.910 - Script 'Workspace.Villager.NPC.QuestScript', Line 28 19:46:16.910 - Stack End Script ends
'nil value' just means that the value is not properly developed or is not input in the first place. In 'Dialogs.dialog[Quest.Value]' lies the main issue, or therefore lack of, as it is equivalent to nil, thus making the script empty to connect to the function. I do not know exactly how to fix it due to lack of context, but have you added a connection to the value? Think about lines 21-26.