Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Making a Quest script and error again?

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!

3 comments

1

'nil value' just means that the value doesn't exist. http://bfy.tw/2w5Y It probably has to do with your module script.

0

Thanks for the help, However I do not understand how to fix it.

1

Dialogs.dialog[Quest.Value] for some reason is equivalent to nil. We can't help much because we don't know the context.

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.