Tips on creating dialogue based on if player has completed an event

I have this setup

return {
	['Guy'] = {
		[1] = {
			'Go and collect these items'
		},
		[2] = {
			'Stage 2'
		},
		[3] = {
			'Stage 3'
		},
	}	
}

And the premis being, when you talk to them, it’ll say everything in [1], until you complete a set task. If you keep talking to them it’ll just keep repeating this until you have completed the task. My question is how could I go about efficiently passing this on?

I fire this when the dialogue is opened

function DialogueControl.speakingTo(character)
	NPC = character
	
	for _, v in pairs(Text[NPC]) do
		print(v)
	end
end

With NPC being ‘Guy’ and thus going through his loops. But I’m not sure how I would go about moving this on once a task has been complete

What you can do is add another value to the table like this maybe

return {
	['Guy'] = {
        current = 1
		[1] = {
			'Go and collect these items'
        
		},
		[2] = {
			'Stage 2'
         
		},
		[3] = {
			'Stage 3'

		},
	}	
}

Whenever the player completes a task set current to the next one so
Text['Guy'].Current = Text['Guy'].Current

And pretty much whenever the dialogue starts

function DialogueControl.speakingTo(character)
	NPC = Text[character] --doing it like this would be simpler
	
	print(NPC[NPC.Current])
end

Maybe you could save the progress somewhere (e.g. a variable named currentTask which would store a numerical value), then use some if statements. Something like if currentTask == 1 then ...

To prevent cheating, RemoteFunctions should be used. For example, when the player clicks on some button that starts the dialog, the client sends a request to the server. The server would grab the NPC name, check the player’s progress, and then return the corresponding dialog list. Or maybe it could return the progress and then the client could load up some locally stored text.

The Roblox Dialogue Editor actually allows you to handle this case very well. You can change the initial prompt a user gets based on a certain condition and control how the dialogue flows. Unfortunately, even though it was set to replace the trashy old C++ dialogue system and stand beside custom dialogue systems, it’s not maintained.

See:

See my post number 77 with this direct link: Official Roblox Dialogue System and Dialogue Editor Beta - #77 by BIoodNeck there’s a maintained version that does work.
Note: The maintained plaugin is by someone else, though.