ive spent long typing this ill send it anyway despite documentation (which im pretty sure also does not document why thread safety exists), also please see bottom message
It could lead to errors, inconsistencies, or even deadlocks and crashes.
Let’s take an example: PVInstance:PivotTo(), which is also not safe to be called in parallel. This is because the Roblox core scripts and internals run on the main thread, which is also where your synchronized threads run. Since it’s all run on one thread, one task can’t interfere with another one.
Parallel Luau provides a second thread for your game’s code to run on, and uses an entirely new Luau VM. This is asynchronous to the other thread; the two of them run at the same time. So, if one modifies the pivot while the other is reading it, it could cause a lot of problems due to the inconsistency in the thread reading it.
But it can go a lot deeper than this. Threads may deadlock each other, where neither can proceed with their respective task, eating up memory and causing issues. It can cause many logic errors and errors thrown, and can really mess up your game.
- Roblox Studio Assistant
This is why you must run these things on the main thread.
the info about thread safety and where roblox core and internals run is from the Studio assistant (excluding the quotes), if it’s wrong blame the assistant
I have a custom wave system that I am trying to get to run smoothly. It currently runs every frame, but I had to sacrifice looks. I currently update the bones that are farther away less often, but that adds some whitespace which looks off.
I use a tile system.
Each tile has 25 bones (5x5 grid)
I can run 20x20 tiles fine with the fix above, but as I said, it looks off.
The main performance hit I found was updating the bones. So, if I could update the positions in different threads, then that issue should be solved.