Hi everyone,
I’m creating a quiz with 1 correct answer and 3 incorrect answers.
Here’s my variable structure (example):
LiteratureQuestions[0]
questionText = “Who wrote Les Misérables?”
correctAnswer = “Victor Hugo”
incorrectAnswers = [ “Edmond Rostand”, “Gustave Flaubert”, “Émile Zola” ]
My goal:
- Display a randomly chosen question → works
- Shuffle the correct answer and the 3 incorrect ones → works
- Display the answers on 4 buttons → not working properly
What I’ve done:
- I pick a random question.
- I add the correct answer to an array
LiteratureQuestions.
- I loop through the incorrect answers:
For each child in LiteratureQuestions[Variable(CurrentQuestion)].incorrectAnswers
Add child to LiteratureQuestions
- Then I shuffle
LiteratureQuestions and assign the first 4 elements to the buttons.
My problem:
- Sometimes there aren’t all 3 incorrect answers (only 1 or 2).
- Sometimes the correct answer doesn’t appear at all.
- I’ve checked that
child is a text variable.
How can I make sure there are always 4 answers before shuffling?
I’m stuck and can’t figure it out 
Thank you all
Hey! Not sure how much this helps, but for my game I made 2 arrays. One contained the questions, and one contained the answers. For the answers, I did 0-3 as the 4 possible answers, and 4 as the correct answer. So each was an array in an array. Example: Apple, Cookie Orange, Banana, Cookie (as which is not a fruit).
hello SnowyRawrGamer
Thank you for your reply.
I’m not a genius
, could you please share or send me a screenshot of your event that handles this action, or of your variable structure, so I can try to replicate it? I’d really appreciate it! 
1 Like
It’s very messy as I’m using it in my game, but:
Hope this can be somewhat helpful
Maybe I’m reading this incorrectly bc of the language difference and Lens’ translation but…
I think you need to use allAnswers on the bottom instead of LiteratureQuestions.
I tried to underline the spots. It’s tough to do on my phone.
Also, the recent versions of GD no longer need the expressions Variable() and VariableString(). You can just use the variable names.
That’s so kind ! thank you !
1 Like
Keith_1357 I will try your advices thank you for your response
1 Like