Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why are my parameters not carrying across functions properly?

Asked by 4 years ago

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.

1 answer

Log in to vote
1
Answered by
iuclds 720 Moderation Voter
4 years ago

You can try ignoring the first parameter in the function and try doing it that way, other wise this is a roblox bug.

0
It works so I suspect you're right and it's just a bug. darkelementallord 686 — 4y
0
Could you mark my answer as a solution? Thanks iuclds 720 — 4y
Ad

Answer this question