Is there any way to put variables inside paths and make the script use the variable? (READ)
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:
01 | function RandomizeTable(tbl) |
05 | table.insert(returntbl,math.random( 1 ,#returntbl+ 1 ),tbl [ i ] ) |
10 | AnswerPositions = { "Correct" , "Incorrect1" , "Incorrect2" , "Incorrect3" } |
11 | AnswerPositions = RandomizeTable(AnswerPositions) |
13 | local AnswerPositions 0 = Question.AnswerPositions [ 0 ] |
14 | local AnswerPositions 1 = Question.AnswerPositions [ 1 ] |
15 | local AnswerPositions 2 = Question.AnswerPositions [ 2 ] |
16 | local AnswerPositions 3 = Question.AnswerPositions [ 3 ] |
18 | print ( "The answer positions are: " ..AnswerPositions [ 1 ] ,AnswerPositions [ 2 ] ,AnswerPositions [ 3 ] ,AnswerPositions [ 4 ] ) |
20 | AnswerBoard 1. Text.Answer.Text = Question.AnswerPositions [ 0 ] .Value |
21 | AnswerBoard 2. Text.Answer.Text = Question.AnswerPositions [ 1 ] .Value |
22 | AnswerBoard 3. Text.Answer.Text = Question.AnswerPositions [ 2 ] .Value |
23 | AnswerBoard 4. 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!