Hello, so I was wondering what would be the best way to handle like a lot of connections in your scripts?
In my module script, I have around 5-6 RunService connections that are being run at the same time, I did use coroutine.wrap for some of them so they can run in multiple threads to prevent any lag or too much usage.
But I don’t know if what im doing is really helpful/effective to improve performance. What do you guys think is recommended to do?
If what you’re doing in the loops is write-safe (you can check if they are on the docs), you could use parallel Luau:
If you’re using parallel Luau and you find yourself having to synchronize frequently (since this negates the benefit of multithreading), and the loops must stay connected, then I’d recommend that you make sure the code doesn’t have to do anything that’s too demanding
I want to note that coroutine.wrap() does not actually create a seperate thread, it just allows 2 code paths to execute on the same thread (essentially it dedicates half of the thread to one and half to the other) which is good for concurrent execution but not performance. Ideally you would consolidate all of your connections into one script that calls modules and use actual multithreading if possible for performance