The following code snippet is simplified code from a returned function within a ModuleScript that I intend to use for error handling:
function errorHandling(func, ...)
local args = {...};
print(unpack(args));
local ran,error = pcall(function()
print(unpack(args));
local results = { func(unpack(args)) };
end);
end
And the following code is the function that is being passed to errorHandling as func:
function func(param1, param2)
print(param1, param2);
end
Now the issue I have is that the first two times I print the unpacked values of the args array it returns the correct values, however when I receive them in the func function and print, the first index has disappeared.
For example, if my arguments (args) are “a” and “b”, my output will show:
a b
a b
b nil
I’ve not been scripting for a few years so it’s probably something simple I’m missing, but I’d appreciate the help.
Update: When I change func(unpack(args)) to func(nil, unpack(args)), the correct parameters arrive in func.