Hello, I am making a trivia/guessing type of game and I want to know if it is possible to assign 2 answers to 1 question in a module script. For example,
My handwriting is terrible, I know. By the way here is the luau formatted version of the code incase you want to make some changes to it to show me:
local module = {
["Name an US President"] = "barack obama",
["Name an Animal"] = "dog",
}
return module
The problem with their code is that #data only returns the amount of things with a numbered index, which anything using a string as the index wouldnāt be counted. Hereās a fix:
local module = {
{
question = "Name an US President",
answers = {"barack obama"},
{
question = "Name an Animal",
answers = {"dog", "cat", "bird"},
},
}
Now, we will need to change the code a bit:
local questionnum = math.random(#data)
local questionobj = data[questionnum]
--then for checking whether or not they had a correct answer
if table.find(questionobj.answers, answer) then
Thank you except theres a problem, whenever I put the questionnum variable as the question text, it is only ā1ā and it somehow prevents my script from going any further.