I have a script that all it does is count the correct questions you answered. a simple quiz.
However there’s an issue that’s related to the numbervalues and no matter on what was attempted, the issue is still there, even with roblox’s AI was sort of helping, but not fixing the problem entirely, as it’s just a simple thing, yet it’s taking hours to find out as to why this is the case.
It could either be the if statement, or the way when the code adds or sets a number to 0.
Video explains the issue at hand.
Here: https://www.youtube.com/watch?v=xoTyZ5pE56I
So the issue stems from the NumberValue, which all it does it count your points. However after it counts past 7 questions, it gives out wrong or unanswered points even tho you know the answer, the game just gives you these other points instead of giving you your correct points.
All the script is looking for is if 2 values are equal to each other, and if they are then you will earn your (Correct Points). If you get the answer wrong, you’ll earn (Wrong Points). And if you don’t answer at all, you’ll get (Unanswered Points)
======================================
If points are equal = Correct:
If points are not equal = Wrong:
If your points are 0 and the answer
has a number, you’ll get unanswered:
======================================
Simple as that, but the outcome is different unfortunately.
Main Game
local QuestionAnswer = script.Parent.QuestionStuff.AnswerValue
local YourAnswerText = script.Parent.Side.InfoFrame.YourAnswerText.Value
local SoundFolder = game.Workspace.QuizSounds
local QuestionPoints = script.Parent.Top.Others
local TimerSpeed = script.Parent.QuestionStuff.TimerSpeed
local TimerFrame = script.Parent.Timer.AmountOfTime
local QuestionImage = script.Parent.QuestionStuff.ImageQuestion
local QuestionCounter = script.Parent.Top.QuestionAmounts
local QuestionThing = script.Parent.MainQuestions.CurrentQuestions:GetChildren()
while wait() do
if game.ReplicatedStorage.initiategamet1.Value == true then
for I,V in pairs(QuestionThing) do
if V:IsA("Frame") then
V.Visible = true
end
end
--YourAnswerText.Value = 0
task.wait(0.125)
script.Parent.Side.InfoFrame.CarImage.Image = (QuestionImage.Value)
TimerFrame.Parent.dotime.Value = true
TimerFrame.Value = (TimerSpeed.Value)
task.wait(TimerSpeed.Value)--Important to keep the quiz running at the same pace as (Question Picker), otherwise the scripts gonna answer questions too quickly
QuestionCounter.QuestionCounter.Value = QuestionCounter.QuestionCounter.Value + 1
-- Debugging statements to track values
warn("Debug: YourAnswerText.Value = " .. tostring(YourAnswerText.Value))
warn("Debug: QuestionAnswer.Value = " .. tostring(QuestionAnswer.Value))
if YourAnswerText.Value == QuestionAnswer.Value then -- Correct Question
SoundFolder.Correct_Answer:Play()
QuestionPoints.CorrectAnswers.CorrectValue.Value = QuestionPoints.CorrectAnswers.CorrectValue.Value + 1
task.wait(1)
YourAnswerText.Parent.Text = "Your Answer:"
warn("Correct!")
elseif YourAnswerText.Value == 0 then -- No Question Answered
SoundFolder.No_Answer:Play()
script.Parent.Side.UnanswerLabel.UAValue.Value = script.Parent.Side.UnanswerLabel.UAValue.Value + 1
task.wait(1)
YourAnswerText.Parent.Text = "Your Answer:"
warn("You didn't answer the question")
else -- Wrong Question
SoundFolder.Wrong_Answer:Play()
QuestionPoints.WrongAnswers.WrongValue.Value = QuestionPoints.WrongAnswers.WrongValue.Value + 1
task.wait(1)
YourAnswerText.Parent.Text = "Your Answer:"
warn("Incorrect!")
end
end
end
QuestionPicker
local QuestionStuff = script.Parent.Parent.QuestionStuff
local QF = script.Parent.Parent.QuestionsFolder
local TextQuestions = script.Parent.Parent.TextQuestions
local TimerSpeed = script.Parent.Parent.QuestionStuff.TimerSpeed
local TimerFrame = script.Parent.Parent.Timer.AmountOfTime
local QuestionScripts = script.Parent.Parent.QuestionScripts
local QuizScore = script.Parent.Parent.Parent.Quiz_Score
-----------------------------------------------------------------------
local function CloneQuestion(q)
local Cloner = q:Clone()
local QuestionScripts = QuestionScripts.QuestionClickFunction:Clone()
Cloner.Parent = script.Parent.Parent.MainQuestions.CurrentQuestions
Cloner.Visible = true
QuestionScripts.Parent = Cloner
QuestionScripts.Enabled = true
--Cloner.RemoveQuestion.Disabled = false
end
-----------------------------------------------------------------------
local function notmvar(t)
local result = {}
for i,v in pairs(t) do
result[i] = v
end
return result
end
local questionsasked = 0
local ingame = true
local questions = {QF.Questions01,QF.Questions02,QF.Questions03,QF.Questions04,QF.Questions05,QF.Questions06,QF.Questions07,QF.Questions08,QF.Questions09,QF.Questions10,QF.Questions11}
local answers = {2,
1,
3,
2,
4,
1,
3,
1,
4,
2,
3}
local answers2 = {0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0}
local image = {"rbxassetid://17835974453",--Q01
"rbxassetid://127216061535849",--Q02
"rbxassetid://15181362257",--Q03
"rbxassetid://132940736500226",--Q04
"rbxassetid://16497808366",--Q05
"rbxassetid://17594381935",--Q06
"rbxassetid://12880245425",--Q07
"rbxassetid://79567965755559",--Q08
"rbxassetid://101926209039454",--Q09
"rbxassetid://91770311840880",--Q10
"rbxassetid://14954219744"}
local load_q = nil
local load_a = nil
local load_i = nil
local function resvar()
oq = notmvar(questions)
oa = notmvar(answers)
oi = notmvar(image)
end
resvar()
local function restart()
questionsasked = 0
questions = oq
answers = oa
image = oi
resvar()
end
while wait() do
if game.ReplicatedStorage.initiategamet1.Value == true then
if #questions ~= 0 then
local rand = math.random(1,#questions)
local RandomQuestion = questions[rand]
--script.Value.Value = RandomQuestion
TimerFrame.Parent.TimerScript.Disabled = false
--print(rand)
CloneQuestion(RandomQuestion)
QuestionStuff.AnswerValue.Value = answers[rand]
QuestionStuff.ImageQuestion.Value = image[rand]
--print("Answer to that question is number: "..answers[rand])
script.Parent.Parent.MainQuestions.QuestionTitle.Text = (TextQuestions.QuestionTextA.Value)
table.remove(questions, rand)
table.remove(answers, rand)
table.remove(image, rand)
task.wait(TimerSpeed.Value+1)--Important to prevent the questions from overlapping each other, even that +1 is needed.
questionsasked += 1
if script.Parent.Parent.QuestionStuff.MaxedQuestion.Value <= questionsasked then
questions = {}
end
else
game.ReplicatedStorage.initiategamet1.Value = false
task.wait(1)
TimerFrame.Parent.TimerScript.Disabled = true
--QuestionStuff.ImageQuestion.Value = ""
script.Parent.Parent.Visible = false
script.Parent.Parent.Parent.Quiz_Score.Visible = true
QuizScore.CorrectPoints.Text = ("Correct: "..script.Parent.Parent.Top.Others.CorrectAnswers.CorrectValue.Value)
QuizScore.WrongPoints.Text = ("Wrongs: "..script.Parent.Parent.Top.Others.WrongAnswers.WrongValue.Value)
QuizScore.UnansweredPoints.Text = ("Unanswered: "..script.Parent.Parent.Side.UnanswerLabel.UAValue.Value)
game.ReplicatedStorage.Results:FireServer("antiexploit35", tostring(game.Players.LocalPlayer).." got a score of ("..tostring(script.Parent.Parent.Top.Others.CorrectAnswers.CorrectValue.Value).." of "..tostring(script.Parent.Parent.QuestionStuff.MaxedQuestion.Value).." Questions) in "..script.Parent.Parent.Gamemode.Value)
restart()
ingame = false
task.wait(1)
end
end
end
print("finished")
QuestionClickFunction
local ValueAnswer = script.Parent.Parent.Parent.Parent.Side.InfoFrame.YourAnswerText
local Buttons = script.Parent
local Timer = script.Parent.Parent.Parent.Parent.Timer.AmountOfTime
local function resetAnswer()
ValueAnswer.Value.Value = nil -- Reset to nil to indicate no answer selected
ValueAnswer.Text = "Your Answer:"
end
-- Reset the answer after each question cycle
resetAnswer()
-- Debug statement to track the reset of the answer
print("Debug: Answer reset to nil")
Buttons.Answer01.MouseButton1Click:Connect(function()
ValueAnswer.Value.Value = 1
ValueAnswer.Text = ("Your Answer: 01")
game.Workspace.QuizSounds.Click1:Play()
print("Clicked 001")
end)
Buttons.Answer02.MouseButton1Click:Connect(function()
ValueAnswer.Value.Value = 2
ValueAnswer.Text = ("Your Answer: 02")
game.Workspace.QuizSounds.Click1:Play()
print("Clicked 002")
end)
Buttons.Answer03.MouseButton1Click:Connect(function()
ValueAnswer.Value.Value = 3
ValueAnswer.Text = ("Your Answer: 03")
game.Workspace.QuizSounds.Click1:Play()
print("Clicked 003")
end)
Buttons.Answer04.MouseButton1Click:Connect(function()
ValueAnswer.Value.Value = 4
ValueAnswer.Text = ("Your Answer: 04")
game.Workspace.QuizSounds.Click1:Play()
print("Clicked 004")
end)
-- Debug statement to track the value of YourAnswerText
warn("Debug: YourAnswerText.Value = " .. tostring(ValueAnswer.Value.Value))
script.Timer.Enabled = true
Here’s where everything is:
Do not write entire scripts or design entire systems, it just need fixing.



