Should I rewrite my gun system into Parallel Lua?

With the release of Parallel Lua, it got me thinking of all different ways it can be used. Above is sort of a logic flow chart. All players use one RemoteEvent and then one serverscript that handles all sanity checks, etc.

However, this one script also handles damage per weapon, cooldown per weapon, etc. So I was wondering, what if I split it up into chunks like there’s one weapon handler per player and they’re all under Parallel Lua?

Would there be a benefit to doing so? My serverscript creates a (at max) 200 distance raycast everytime it’s fired. It can somewhat drive up script activity with 10ish players all shooting at once.

1 Like

I think that multithreading adds a lot of complexity to your code, and you should think carefully about whether that tradeoff is worth it.

Script activity by itself doesn’t tell you a whole lot. If you’re running into performance bottlenecks, you can try using the Using MicroProfiler | Roblox Creator Documentation to diagnose them. But don’t multithread before you’ve tried every other option for optimizing.

I am also not certain that multiple Lua threads would speedup things like networking or physics in the first place.