I’m try to make a module multiple choice system using tables but it printed out “attempted to index nil with Choices”
Here my local script:
local Module = require(script.Parent.ModuleScript)
local QuestionText = script.Parent.Frame.Question
local ButtonHolder = script.Parent.Frame.ButtonHolder
local Debounce = false
for i = 1, 2 do
Debounce = false
for _, Choices in pairs(Module[i].Choices) do
local textButtonClone = game.ReplicatedStorage.TextButton:Clone()
textButtonClone.Parent = ButtonHolder
textButtonClone.Text = Choices
textButtonClone.MouseButton1Click:Connect(function()
if textButtonClone.Text == Module[i].Answer then
print("You got it right")
Debounce = true
else
print("Try again")
end
end)
end
repeat task.wait() until Debounce == true
end
My module script:
local module = {
Question1 = {
Question = "What color is a strawberry",
Choices = {"Yellow", "Purple", "Green", "Red"},
Answer = "Red"
},
Question2 = {
Question = "What 5 + 3",
Choices = {"8", "3", "12", "9"},
Answer = "8"
},
}
return module