What’s is connect parallel. I have messed around and all it does is throw errors. What am I missing

Every time I’ve typed connect in I am met with connect parallel I know this isn’t a new feature per say and I don’t think it’s one of those engine features either. I can’t find nearly anything online at all and what I did find makes. Zero sense and seems overly advanced almost non rbx lua looking their must be something I am not getting I tinkered with it a lot and couldn’t even get it into code without causing a error

Never seen snippets of code using it in the toolbox or dev forum besides a couple painfully long confusing posts

Or is this one of those keywords/builtins like :getdescendants that does nothing?

When we use Connect() or Once() the code is ran in a new thread. But those threads are not real CPU threads, they are coroutines that give impression of running in parallel, while in fact they are resumed one at a time by the task scheduler.

Functions like ConnectParallel() are used for running code on actual different CPU threads in specific cases, especially when we want to split a very demanding task like terrain generation between CPU cores to speed up the process. It’s done in scripts parented to Actors.

An actor can receive a message in a synchronised state (e.g. Event:Connect()) and desynchronise afterwards, but if an event is listened to using ConnectParallel(), it is automatically ran in parallel context, making the context switching more efficient.

bindableEvent:Connect(function(message) task.desynchronize() end)
-- or
bindableEvent:ConnectParallel(function(message) end)

An error is raised because it can only be called if the script is in an actor.

P.S.: :GetDescendants() has a very valid usage. It returns a flat (1D) array of all instance’s descendants: children, children of the children …

4 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.