local function code1()
print("text")
end
local function code2()
task.wait(1)
end
local code = {code1, code2}
local number = 1
code[number]() -- Will print "text"
another thing you can do is enclosures which let you generate functions at runtime (ie changing code based off variables):
function enclosure(a)
local function newfunc(b)
return a + b
end
return newfunc
end
local enclosedfunc = enclosure(2)
print(enclosedfunc(2)) -- outputs 4