It is too hard to get the Parallel Luau Actor that a ModuleScript is running in

As a Roblox developer, it is currently too hard to identify if a ModuleScript is being called from an Actor. The Instance:GetActor() method just returns if the instance is a descendant of an Actor, not if the execution context of the module is inside an Actor or not.

Our game (SCI - Pathos III - Roblox) uses shared library code across various games, some of which use Parallel Luau heavily and some of which do not. Likewise, some scripts in the game are not Parallelized or inside of an Actor.

This means that it’s difficult to make shared library code which optionally uses Parallel execution phases for performance increases, and we’re required to stub the code to be parallel or expose a Parallel equivalent method, leading to code duplication. (i.e. GetClosestPlayer and GetClosestPlayerParallel).

It also means that subscribing to Cross-Actor Messaging within Modules is difficult because you only get the Actor that the ModuleScript is a descendant of, not the Actor that code is running in.

I’d ideally like some kind of method accessible by any LuaSourceContainer which would either return the specific Actor that ModuleScript is running in, but the use case would mostly be met by a method returning if the ModuleScript was required within an Actor or not.

If Roblox is able to address this issue, it would improve my development experience because I would be more easily able to adopt Parallel Luau, and its performance benefits, into games without breaking use cases that don’t use Parallel.

12 Likes

I agree. It would be great to figure out if the currently executing coroutine can have the desynchronize or synchronize functions called. Maybe another function could be added to the task library that returns a boolean to tell us if we can.

2 Likes