I'm making a questionnaire game in ROBLOX, and I have a StringValue. I want to randomly select an answerbox so people aren't like "top left is always correct". I have a table. The table values are the names of the incorrect/correct answers. When I run the game, it's trying to use the string form: "AnswerPositions" instead of the variable form, which could be "Correct", "Incorrect1", "Incorrect2" or "Incorrect3". This is because it isn't checking and using the variable form. How do I make it do this?
Here is my code for reference:
function RandomizeTable(tbl) --Table Randomizer Function
local returntbl={}
if tbl[1]~=nil then
for i=1,#tbl do
table.insert(returntbl,math.random(1,#returntbl+1),tbl[i])
end
end
return returntbl
end
AnswerPositions={"Correct","Incorrect1","Incorrect2","Incorrect3"}
AnswerPositions=RandomizeTable(AnswerPositions)
local AnswerPositions0 = Question.AnswerPositions[0]
local AnswerPositions1 = Question.AnswerPositions[1]
local AnswerPositions2 = Question.AnswerPositions[2]
local AnswerPositions3 = Question.AnswerPositions[3]
print("The answer positions are: "..AnswerPositions[1],AnswerPositions[2],AnswerPositions[3],AnswerPositions[4])
AnswerBoard1.Text.Answer.Text = Question.AnswerPositions[0].Value
AnswerBoard2.Text.Answer.Text = Question.AnswerPositions[1].Value
AnswerBoard3.Text.Answer.Text = Question.AnswerPositions[2].Value
AnswerBoard4.Text.Answer.Text = Question.AnswerPositions[3].Value
Here is my error message for reference: 00:40:30.926 - AnswerPositions is not a valid member of StringValue
Get me a working fix and I'll mark your post as correct!

1 comment
can you send me an image of Question's hierarchy?