In regular Lua, it is possible to dynamically create and load in all local variables of the current scope into a table using debug.getlocal, but ROBLOX has removed every single useful function that is supposed to be in the debug library.
Yet, it is still easy to dynamically create global variables in ROBLOX's Sand-boxed Lua:
local my_env = getfenv(1);
for i = 1, 10 do
my_env["OMG_DYNAMIC_GLOBAL_VARIABLE_"..i] = i * i;
end
The fact that you can do this in ROBLOX is great, however local variables are accessed much faster than globals due to locals being stored in virtual registers.
I remember reading somewhere on the internet that it is possible to load all local variables residing in the current scope into a table without using the debug library, but I can't find it anywhere now.
Here is some pseudo code for the two things I am trying to accomplish:
for i = 1, 10 do
local["OMG_DYNAMIC_LOCAL_VARIABLE_"..i] = i * i;
end
and
local LocalVars = {(local)} --somehow load all local variables into this table
for i,v in pairs(LocalVars) do
print(i, v);
end
I would appreciate any help. Thanks

2 comments
i dont really understand what u mean, do u mean so all of the variables like go at the same time?
When you create a variadic index inside of a table in Lua, you typically type my_table[i] = v; This is dynamically creating an index/value inside of a table (because the i and v are not static values in this case), and you can create dynamic global variables in the same manner, however not local variables in the current scope; which is why I am wondering how you can implement this with locals