Having trouble with my quest system

I’m following Spook’s Youtube guide, but I must have made a mistake somewhere (again). When I take the quest from the NPC, It’s supposed to create a quest in the GUI, but for some reason it’s not making it that far.
Output
I’ve put print in a few places, and I’m not getting any errors, so it’s making this hard for me to figure out.
These are from the Module Script in Starter GUI



This is the related module, Quests, in Replicated Storage
QuestsModule
I know it adds the quest to my profile because I’m watching my profile in this box.
ProfileImage1

Please help!

Think you can copy-paste the code into a code block? Much easier than reading through screenshots.

function doQuestUpdate()
	--print("Quest Received")
	if not activeData then
		return
	end

	local questIDCache = { }
	--print("checked for active data")
	for _, questData in ipairs(activeData.Quests) do
		--print ("Searching for Quest ID")
		local questConfig = QuestConfig.GetQuestFromID(questData.ID)
		if not questConfig then
			print("quest not already taken")
			continue
		end
		print("QuestData inserting into table")
		table.insert(questIDCache, questData.ID)
		print("table inserted")
		local activeFrame = Interface.QuestsFrame:FindFirstChild(questData.ID)
		if not activeFrame then
			activeFrame = TemplateQuestFrame:Clone()
			print("Frame Template cloned")
			activeFrame.Name = questData.ID
			
			for propertyName, propertyValue in pairs(questConfig.Display.Title) do
				activeFrame.Title[propertyName] = propertyValue
			end
			
			for propertyName, propertyValue in pairs(questConfig.Display.Description) do
				activeFrame.Description[propertyName] = propertyValue
			end	
			
		end
		activeFrame.BarBack.Label.Text = questData.Contributions.."/"..questConfig.RequiredContributions
		activeFrame.Parent = Interface.QuestsFrame
		LTweenSize(activeFrame.BarBack.Bar, UDim2.fromScale(questData.Contributions/questConfig.RequiredContributions, 1))
	end
	
	--removes old quests
	for _, Frame in ipairs(Interface.QuestsFrame:GetChildren()) do
		if Frame:IsA("Frame") and not table.find(questIDCache, Frame.Name) then
			Frame:Destroy()
		end
	end	
end

function OnDataUpdate()
	Interface["Data Label"].Text = "Data: "..(activeData and HTTPService:JSONEncode(activeData) or "No Data")
--	print("Data Updated")
	doQuestUpdate()
end

sorry but can you use darkmode when taking screenshots would help because majority of the platform doesnt use light mode, and right now its straining my eyes reading

I’m also having problems with the contributions part of the quest (not sure if these are related).

From the output:
ServerStorage.Systems.QuestService:42: invalid argument #1 to ‘find’ (table expected, got nil) - Server - QuestService:42
11:13:26.876 Stack Begin - Studio
11:13:26.876 Script ‘ServerStorage.Systems.QuestService’, Line 42 - function ContributeToQuests - Studio - QuestService:42
11:13:26.876 Script ‘Workspace.Harvestables.Proximity Harvests.Berry Groups.Berries for Harvesting.BerryParts.Berry.HarvestController’, Line 12 - Studio - HarvestController:12
11:13:26.877 Stack End - Studio

function module:ContributeToQuests(LocalPlayer, contributionID, amount)
	local playerProfile = DataService:GetPlayerProfile(LocalPlayer)
	if playerProfile then
		for index, questData in ipairs(playerProfile.Data.Quests) do
			local questConfig = QuestData:GetQuestFromID(questData.ID)
			if not questConfig then
				continue
			end
			--adds to contrubtion count
			if table.find(questConfig.Contributors, contributionID) then
				questData.Contributions += (amount or 1)
				if questData.Contributions >= questConfig.RequiredContributions then
					table.remove(playerProfile.Data.Quests, index)
					questConfig.Reward(LocalPlayer, playerProfile)
				end 
			end
		end
	end
end

this is in the questService module, and it’s being called from the Harvest controller script:

ProximityPrompt.Triggered:Connect(function(LocalPlayer)
	QuestService:ContributeToQuests(LocalPlayer, "onCollect_Berry")
	ProximityPrompt.Enabled = false
	for i, part in ipairs(BerryParts:GetChildren()) do
		part.Transparency = 1
		end
	wait(5)
	for i, part in ipairs(BerryParts:GetChildren()) do
		part.Transparency = 0
	end
		ProximityPrompt.Enabled = true
end)

Reference line:

if table.find(questConfig.Contributors, contributionID) then

According to the error, questConfig.Contributors is nil.

Maybe I’m just referencing it wrong, but it is there

questModule.TutorialQuests = {
		{
			ID = "TutorialQuest", 
			Display = {
				Title = {
					Text = "Harvest 3 Berries.",
					TextColor3 = Color3.new(1,1,1)
					},
				Description = {
					Text = "NadinaKitten has asked you to gather 3 berries for her.",
					TextColor3 = Color3.new(1,1,1)
					},
			Contributors = {"onCollect_Berry"},
				RequiredContribtions = 3,
				},
			Reward = function(LocalPlayer, playerProfile)
				playerProfile.Data.Gold += 10 
			end,
			Currency = "Gold"
		},		

unless I’m doing something wrong here:

function module:CreateDataForQuest(questData)
	return {ID = questData.ID,
		Contributions = 0}
end

function module:PlayerHasQuest(playerProfile, questID)
	for _, questData in ipairs (playerProfile.Data.Quests) do
		if questData.ID == questID then
			return questData
		end
	end
end

function module:AddQuestToPlayer(LocalPlayer, questID) --confirmed this function works
	local questData = QuestData:GetQuestFromID(questID)
	local playerProfile = DataService:GetPlayerProfile(LocalPlayer)
	if questData and playerProfile then
		if not module:PlayerHasQuest(playerProfile, questID) then 
			local newDataQuestData = module:CreateDataForQuest(questData)
			table.insert(playerProfile.Data.Quests, newDataQuestData)
		end
	end	
end

I think I found the problem. But I still haven’t completely solved the original issue.

Found it. had a “.” where I needed a “:”

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.