Hello! I am creating a quest system for my project… and i’ve run into a small roadblock… nothing super big or system breaking… its more a paramater that could fail. So… in the npc’s dialogue that is only active for a quest, and this is the end of the quest… when you reach a certain dialogue point it detects in the place where i store the dialogue if it should complete the quest… which it then sends to a module with this code:
function Quest_Controller:Complete_Quest(Quest)
print("JUST Gompleted a QUEST", Quest, Quests[Quest]["Quest_Description"])
local Player_NPC_Info = player:WaitForChild("Player_NPC_Info")
local Player_Quest_Data = player:WaitForChild("Player_Quest_Data")
if Quests[Quest]["Quest_Type"] == "Find_NPC" then
local CompletedParamaters = {}
local Completed
for i,v in pairs(Quests[Quest]["Quest_Objective"]) do
for t,w in pairs(Player_NPC_Info:GetChildren()) do
if w.Name == v then
if w:FindFirstChild("Status") == "Inactive" and Player_Quest_Data:FindFirstChild(Quest):FindFirstChild("Active") == true then
Completed = true
else
Completed = false
end
end
end
end
if Completed then
print("Running Completed Quest Thing")
Quest_Data_Service.Completed_Quest_Event:Fire(Quest, true)
end
end
end
Essentially what my problem is… sometimes… in this case for this paramatered type of quest which is “Find_NPC”, meaning… you are sent to an npc and must talk to them, and if that is the case it runs this. This may also include talking to several NPC’s. And if so, then the paramater i have for completed, which i want to be active only if ALL of the npc’s required have been spoken too, will activate. But the way i have it now, it will not guarantee that the completed value will be correct at all times.
You see… the function will run every time one of the classified objective npc’s is spoken too in their dialogue. Imediately after these NPC’s are spoken to and the dialogue completes it sets them to “Inactive” which is what i’m searching for in the function. If all of the NPC’s are set to Inactive, then the Completed value will become true… and the following if statement can be fullfilled.
My question is… what should i do to check if ALL the NPC’s are set to “Inactive”? And if they are ALL Active, then it will activate the Completed Value.