What is most efficient way of handling module questions?

I am making a GUI where you are able to fetch questions from a module and then return them into a text label with the needed answer after so how could I detect whatever I scan through has specific word to tell the script its the question variable than anything else?

local FAQs = game.ReplicatedStorage.FAQs
local Module = require(FAQs[script.Parent.Parent.Text])
local Menu = script.Parent.Parent.Parent.Parent

script.Parent.Activated:Connect(function()
	local Sample = Menu.QuestionSample
	Sample:Clone()
	Sample.Visible = true
	Sample.Name = Module.Name
	
	for i,v in pairs(Module) do
		
	end
end)
local Info = {
	Name = "Jailbreak";
	Q1 = "How to rob?";
	Q2 = "Whats most expensive item?";
	Q3 = "Where is the bank?";
	
	A1 = "Go into a vault";
	A2 = "Jet";
	A3 = "The city";
}

return Info

I’d be nice if there was also a way for the script to find Q1 and then search for anything containing A with the same integer to save it as the answer

1 Like

If I understand correctly, you can use nested tables.

local questions = {
{
set_name = "Jailbreak";
questions = {"Q1", "Q2", "Q3"};
answers = {"A1", "A2", "A3"}; 
};
}

You can then iterate through each table in questions to find the question you need by reading the set_name variable. Then, iterate over the questions and answers tables as needed.

Hope this helps