Quest System: Printing/Array Issue

Hello there, for the past few days I’ve been making a Quest System. However, I’ve stumbled across an issue that I have been trying to solve for a few hours.

Above is a picture of my issue. The QuestsCompleted folder has 2 quests that are completed. However, whenever I try to print it into the output, it only says that one quest is completed. This only occurs after I’ve successfully completed the first quest for some reason. If needed, I will add the entire Quest script as well.

Here is what my module script looks like:

local QuestLine1 = {
	CharacterName = 'John';

	Quests = {
		[1] = {
			Objective = "Find John's Shovel";
			QuestNum = 'Quest1',
			
			Requirements = {
				Shovel = 1, -- Shovel is the name of the thing you need to collect; 1 is the value of it that you need to collect so in this case you need to colllect ONE shovel
			--	Honey = 1000,
			
			};
				
			Description = {
				'Hello, I need some help.',
				"I can't seem to find my shovel.",
				'Hello I am weird.',
				'I am not feeling good.',
				'Could you please find it for me?',
			};
			
			Completed = {
				"Hey, you found it! Thanks for finding my cat. As a reward, I'll give you some COINS.",
			};
			
			InCompleted = {
				'Please come back when you have found my shovel.',
			};
		};
		
		[2] = {
			Objective = 'Blah blah',
			QuestNum = 'Quest2',
			
			Requirements = {
			--	Honey = 1000,
				Food = 2,
				IceCream = 5,
			
			};
			
			Description = {
				'Hey there, Im John!',
				'I need some help if you do not mind.',
				'Could you please help me collect some food and icecream for the nearby vendors?',
				'Thanks alot!'
			};
			
			Completed = {
				"Hey thanks a lot!",
			};
			
			InCompleted = {
				'Please come back when you have colleted all of the items!',
			};
		};
		
		[3] = {
			Objective = 'Boomer',
			QuestNum = 'Quest3',
			
			Requirements = {
			--	Honey = 1000,
				Food = 2,
				IceCream = 5,
			
			};
			
			Description = {
				'Hey there, Im noobie!',
				'I need some help if you do not mind.',
				'Could you please help me collect some food and icecream for the nearby vendors?',
				'Thanks alot!'
			};
			
			Completed = {
				"Hey thanks a lot!",
			};
			
			InCompleted = {
				'Please come back when you have colleted all of the items!',
			};
		};
	
};

}

return QuestLine1

Thanks a lot in advance.

I would look further into this. For now, I would suggest you to not specify i in the for loop as you do not really need it, not sure if that has anything to do with your case but it has helped me once.

I will try that. Thanks.
30charssss

Could you provide the rest of the loop? Preferably where you’re printing out ‘quest2’

1 Like

Here is the rest of the loop. Also, the ‘QuestOn’ indicates which quest the player is on. (Ex. If QuestOn is equal to 2 then the quest the player is on is Quest2)

UIS.InputBegan:Connect(function(input, gpe)
	if gpe then return end
	
	if input.KeyCode == Enum.KeyCode.E then
		if Target == "" or Target == nil then print'nothing found yet' return end
		
		print(Target)
		
		local getTarget = Quests:WaitForChild(Target)
		if not getTarget then warn'fatal error could not get target' return end
		
		local Module = require(Storage:WaitForChild("Quests").Quests:WaitForChild(getTarget.QuestName.Value))
		
		
		for _,questName in pairs(Module['Quests']) do
			warn(questName['Objective'], questName)
			
			for i,v in pairs(Players:WaitForChild("QuestsCompleted"):GetChildren()) do
			
				if  v.Name == (questName['Objective']) then
					QuestOn = 1
					warn(v.Name.. ' are quests found. oof')
					
					QuestOn = QuestOn + 1
					
					local Combine = (QuestOn)
					warn(Combine)
					
					local Dialogue = Module['Quests'][Combine]['Description']
					
					for i = 1, #Dialogue do
						MaxDescription = i
					end
					
					updateDialogue(Dialogue[CurrentNumber])
					
					if Frame.Open.Value == false then
						updateDialogue(Dialogue[CurrentNumber])
						
				
						Frame:TweenPosition(UDim2.new(0.286,0,0.215,0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.5, true)
						Frame.Open.Value = true
				elseif Frame.Open.Value == true then
							
					Frame:TweenPosition(UDim2.new(0.286,0,-1,0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.5, true)
					Frame.Description.Text = ''
							
					Frame.Open.Value = false
					CurrentNumber = 1 
				end
			end
			
			 warn'nani' return end -- checking if player has done quest already
			
			local Dialogue = Module['Quests'][(QuestOn)]['Description']
			print'test againnn'
				
			for i = 1, #Dialogue do
				MaxDescription = i
			end
				
			updateDialogue(Dialogue[CurrentNumber])
				
			print(CurrentNumber)
					
			
			if Frame.Open.Value == false then
				updateDialogue(Dialogue[CurrentNumber])
					
			
				Frame:TweenPosition(UDim2.new(0.286,0,0.215,0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.5, true)
				print'what?'
				Frame.Open.Value = true
				QuestOn = 1
			elseif Frame.Open.Value == true then
						
				Frame:TweenPosition(UDim2.new(0.286,0,-1,0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.5, true)
				Frame.Description.Text = ''
						
				Frame.Open.Value = false
				CurrentNumber = 1 
			end
		end
	end
end)