So what I'm trying to do is, there is a randomly generated code that is put into the "array" table, and it prints the first item from that table. And when I use the printed code from the output, and put it into the textbox, and click the button, it doesn't print anything. I'm using tonumber because any number put into a textbox is a string, please help.
local array = {}
local textBox = script.Parent.Parent.TextBox
while true do
local randomValue = math.random(100,9999)
table.insert(array, randomValue)
wait(1)
print(array[1])
end
script.Parent.MouseButton1Click:Connect(function()
if textBox.Text == table.find(array, tonumber(textBox.Text)) then
print("Code successful")
else
print("Code unsuccessful")
end
end)

3 comments
If you read the code, you'd realize that they're inheriting the text property (which is dynamic, you should know TextBox's are used to write text into...) upon the click of a supposed confirmation TextButton.
The actual issue lies within the while loop, it's yielding the thread.......
@ack_superbear, you can resolve this quickly by spawning the loop in a separate thread with spawn(), research this on the Developer Wiki to learn how to apply it.