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

'Spawn function requires 1 argument' but the given function is executed?

Asked by 9 years ago

EDIT: sorry about that, I fixed it. I guess writing down the whole problem after 2 days made me think about it differently. It seems that instead of giving the function to Spawn it's instead executed as an argument, given that the function has no return value means no arguments hence the error.... dope.

This is a problem I don't understand. Basically a function is called from a table, but I wanting it to run on another 'thread' I use the Spawn() function(note: i receive a similiar error from coroutine.wrap()) . In doing this the function is executed and "okay" is printed, but the script stops with the following error:** 'Spawn function requires 1 argument' **

I did manage to break down the issue into a small snippet of code.

local events = {
    {function()
        print("okay")
    end}
}

for _,slot in pairs(events) do
    for _,event in pairs(slot) do
        print(event)
        Spawn(event())
    end
end

Answer this question