I’m making a verification system, and I basically asking: Choose number: Three
And then having 4 numbers that display like this:
1 3
8 2
When you choose number three, you can move on.
But i’ve ran into a problem, I have a function that always returns different numbers than the others when its called, but I can’t get it to work with numbers that are spelled out. Now, I would use something like this: Choose number: 3. I but I bet this can be bypassed very easily. So please, tell me how if there is a way.
The entire script
local numbers = {1,2,3,4,5,6,7,8,9,0}
local numberNames = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Zero"}
local RandomButton = {1,2,3,4}
local generatedNumbers = {}
local QuestionLabel = script.Parent.QuestionLabel
local CorrectNum = script.Parent.CorrectNum
local t1 = script.Parent.t1
local t2 = script.Parent.t2
local t3 = script.Parent.t3
local t4 = script.Parent.t4
local QuestionLabelAnswer
local Correct
local function uniquePseudoRandomGenerator(lower : number, upper : number) : number
if upper - lower + 1 == #generatedNumbers then print("err") end
local randomNumber
repeat
randomNumber = math.random(lower, upper)
until not table.find(generatedNumbers, randomNumber)
table.insert(generatedNumbers, randomNumber)
return randomNumber
end
local function RandomVerify()
task.wait(0.42)
CorrectNum.Value = uniquePseudoRandomGenerator(1,#numberNames)
QuestionLabel.Text = "Choose number: "..CorrectNum.Value
if CorrectNum.Value == "One" then
QuestionLabelAnswer = 1
elseif CorrectNum.Value == "Two" then
QuestionLabelAnswer = 2
elseif CorrectNum.Value == "Three" then
QuestionLabelAnswer = 3
elseif CorrectNum.Value == "Four" then
QuestionLabelAnswer = 4
elseif CorrectNum.Value == "Five" then
QuestionLabelAnswer = 5
elseif CorrectNum.Value == "Six" then
QuestionLabelAnswer = 6
elseif CorrectNum.Value == "Seven" then
QuestionLabelAnswer = 7
elseif CorrectNum.Value == "Eight" then
QuestionLabelAnswer = 8
elseif CorrectNum.Value == "Nine" then
QuestionLabelAnswer = 9
elseif CorrectNum.Value == "Zero" then
QuestionLabelAnswer = 0
end
Correct = RandomButton[math.random(1,#RandomButton)]
if Correct == 1 then
t1.IsCorrect.Value = true
t1.Number.Text = QuestionLabelAnswer
elseif Correct == 2 then
t2.IsCorrect.Value = true
t2.Number.Text = QuestionLabelAnswer
elseif Correct == 3 then
t3.IsCorrect.Value = true
t3.Number.Text = QuestionLabelAnswer
elseif Correct == 4 then
t4.IsCorrect.Value = true
t4.Number.Text = QuestionLabelAnswer
end
for i,v in pairs(script.Parent:GetChildren()) do
if v.Name == "t1" or v.Name == "t2" or v.Name == "t3" or v.Name == "t4" then
if v:WaitForChild("IsCorrect").Value ~= true then
v:WaitForChild("Number").Text = uniquePseudoRandomGenerator(1,#numbers)
end
end
end
end
t1.MouseButton1Up:Connect(function()
if t1.IsCorrect.Value == true then
task.wait(1)
t1.IsCorrect.Value = false
RandomVerify()
end
end)
t2.MouseButton1Up:Connect(function()
if t2.IsCorrect.Value == true then
task.wait(1)
t2.IsCorrect.Value = false
RandomVerify()
end
end)
t3.MouseButton1Up:Connect(function()
if t3.IsCorrect.Value == true then
task.wait(1)
t3.IsCorrect.Value = false
RandomVerify()
end
end)
t4.MouseButton1Up:Connect(function()
if t4.IsCorrect.Value == true then
task.wait(1)
t4.IsCorrect.Value = false
RandomVerify()
end
end)
RandomVerify()