Attempt to load function from different lua vm

Hello there. I’m working on a script that involves some parallel lua (Because why not), and I’m getting this weird error “Attempt to load a function from a different Lua VM”. I don’t want to show code unless it’s absolutely needed.

The way I get this error, is I have a script that creates a class from a module that I have. There is also a bindable function that I have all hooked up that allows scripts within actors to request the created class. And the bindable function will return this class.

Within the script that runs inside the actor, it invokes the bindable function, and within the script that creates the classes, it returns the requested class. Then the script inside the actor that requested this class tries to call a function within that class, which is where the error occurs.

Is there any way I can fix this? Or get around this in some way?

Perhaps this link can help you further. Without code its going to be hard to decrypt your message in my opinion

1 Like

Why do you create the class in a script instead of creating it in the module script and then just requiring the module script in the scripts under the actors? I thought that module scripts could be required by scripts under actors although every vm would get its own copy of the modulescripts data, but I may be wrong as I haven’t used parallel lua.

I don’t want each actor’s script to create a new class when it’s started. I want just one class, and I want each actor’s script to access that one class. But I’ll try to find a different way to do this, I have some ideas.

Call task.synchronize() then cache the class to q variable then call task.desynchronize() after all in your parallel connection

So, I call task.synchronize(), then request that class from that script, then call task.desynchronize() at the end of the parallel connection?