You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I have a surfacegui for quiz that im making, when the player clicks a proximity prompt it starts the quiz and when the player clicks the correct option for the question it goes to the next question
- What is the issue? Include screenshots / videos if possible!
The problem is that whenever I try to make it so when a certain option is clicked when a certain question is present that it cycles to the next question, its always broken and never works as intended (for example, if the current question index is 3 and the correct answer is option 2, even if i press option 1 or 3 it still cycles for some reason)
-
What solutions have you tried so far? Did you look for solutions on the
Developer Hub?
I have, I have tried to change the question index instead of reloading the function itself, but it never works.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local accessVerifiedEvent = rs.AccessVerified
local toggle = true
local on = false
local turnOn = false
local Screen = workspace:WaitForChild("OpenGateAccess")
local Mainframe = Screen.SurfaceGui.MainFrame
local QuizFrame = Mainframe.QuizFrame
local option1 = QuizFrame.Option1
local option2 = QuizFrame.Option2
local option3 = QuizFrame.Option3
local correctSound = Screen.Correct
local wrongSound = Screen.Wrong
local quizQuestions = {
[1] = "What is 3x9?",
[2] = "Who are you?",
[3] = "What is your purpose here?"
}
local option1Answers = {
[1] = "27",
[2] = "Michel",
[3] = "To expand sector C"
}
local option2Answers = {
[1] = "21",
[2] = "Darinje",
[3] = "To fix radon leaks"
}
local option3Answers = {
[1] = "25",
[2] = "Mikaeli",
[3] = "To repair subdiffuser 2"
}
local function randomizer()
local chooseRandom = math.random(1, #quizQuestions)
return chooseRandom
end
local function loadQuestion(fromOption)
Mainframe.VerifyAccessText.Visible = false
QuizFrame.Visible = true
Screen.ProximityPrompt.Enabled = false
Screen.Click:Play()
if on == false then
if turnOn == true then
on = true
turnOn = false
end
local chooseRandom
chooseRandom = randomizer()
if fromOption == 0 then
on = false
turnOn = true
end
QuizFrame.QuizQuestion.Text = quizQuestions[chooseRandom]
option1.Text = option1Answers[chooseRandom]
option2.Text = option2Answers[chooseRandom]
option3.Text = option3Answers[chooseRandom]
if chooseRandom == 1 then
if fromOption == 1 then
correctSound:Play()
chooseRandom = randomizer()
end
end
if chooseRandom == 2 then
if fromOption == 3 then
correctSound:Play()
chooseRandom = randomizer()
end
end
if chooseRandom == 3 then
if fromOption == 2 then
correctSound:Play()
chooseRandom = randomizer()
end
end
end
end
option1.MouseButton1Click:Connect(function()
loadQuestion(1)
end)
option2.MouseButton1Click:Connect(function()
loadQuestion(2)
end)
option3.MouseButton1Click:Connect(function()
loadQuestion(3)
end)
Screen.ProximityPrompt.Triggered:Connect(function()
loadQuestion(0)
end)
Code for the quiz