You need to tell the interpreter Q..math.random(1,10)
is one string like this:
local current_question = questions.EN["Q"..math.random(1,10)][1]
Domanda
local questions={
EN={
Q1={"",""},
Q2={"",""},
Q3={"",""},
Q4={"",""},
Q5={"",""},
Q6={"",""},
Q7={"",""},
Q8={"",""},
Q9={"",""},
Q10={"",""}
},
BR={
Q1={"",""},
Q2={"",""},
Q3={"",""},
Q4={"",""},
Q5={"",""},
Q6={"",""},
Q7={"",""},
Q8={"",""},
Q9={"",""},
Q10={"",""}
},
TR={
Q1={"",""},
Q2={"",""},
Q3={"",""},
Q4={"",""},
Q5={"",""},
Q6={"",""},
Q7={"",""},
Q8={"",""},
Q9={"",""},
Q10={"",""}
}
}
local current_question = questions.EN.Q..math.random(1,10)[1]
I want to make the current_question
variable return a random question from the questions
table but it gives me an error; "attempt to index ? (a number value)"
Soluzione
You need to tell the interpreter Q..math.random(1,10)
is one string like this:
local current_question = questions.EN["Q"..math.random(1,10)][1]