What do you want to achieve?
I would like to receive the code contained in the generated generateCode(), I am trying to use a variable for this, but it does not work as I would like, i.e. I generate the same number (screenshot)
local id = {}
function genCode()
local tempcode = math.random(1,999)
if table.find(id, tempcode) then
task.wait()
genCode()
else
table.insert(id, tempcode)
return tempcode
end
end
local code = genCode()
It won’t. You already called the function in the code variable once and that variable has been set to the value that has been returned by the function.
That’s why when you print it, it shows you the same value over and over again.
When you call the function like print(genCode()) however, it prints out a new one since you’re calling the function again.