I need help making a question system

Hi, i wanted to ask i need MASSIVE help with making a question system or i guess more like a answering system, smth like this please forget the art work…

So what i have tried is to make an array (because i want tons of questions) but i also need for that question that there is giving aka the things the answers will give like +10 happy or smth, so i tried making an array in array so that it could choose a random question while also having propertys that will be given (i didnt explain that well sorry) but bassicly that didnt work so i searched and searched and searched i thought the best thing to do is make alot of arrays to hold a ton of items but i didnt want to make 500 arrays to store a million items so i tried dictionary but i just couldnt figure it out, i really need this i really dont want another project to go to the dumps, i really hate asking like this but i really cant find anything that can help, please

1 Like

Something like this? Array of objects

local questions = {
{ question = "question text here", answers = { "yes", "no" } }
}
1 Like

Yeah i need something like that can hold the question what will the yes answer give like +10 happy and what will the no answer give like -10 happy

1 Like

In that case,

local questions = {
{ question = "question text here", answers = { {"yes", 10}, {"no", -10} } }
}

where the 1st member in the array of answers is the answer text, and the 2nd member is the amount of stat to give

1 Like

But could i make multiable of thoso like mini arrays so there is like question 2 and 3, and could it be able to be chosen randomly like array like:

print(questions[math.random(1,#questions)])

Yeah, it’s an array, its indices are numbers

1 Like

Here is an example on how i would atleast try to do it:

local dictionary = {
  [1]= {
    Question = "Do you like me?",
    Answers = {{"Yes i do!",10},{"No i dont",-10}}
  }
}

local function getQuestion()
  local chosenQuestionArray = math.random(1,#dictionary)
  local chosenQuestion = chosenQuestionArray.Question
  local chosenAnswers = chosenQuestionArray.Answers
 -- and so on i think you get it
end

You can use a loop in answers so that it auto creates the boxes for every answer there is with the value.
Im unsure if this is syntax correctly so lmk

I recommend going OOP with this and make a class that constructs questions then putting them in an array to make it easier.