I already have a somewhat functional moving parts system. In studio works completely fine, but in game starts to bug and become an reliable. This is for a mini-game based game where a server script is constantly adding and deleting parts from the Workspace.
I was just wondering on the best way to code something like this. What I have currently is a local script that detects when the part is spawned in and then will use the spawn() function with a module script.
hey, whats exactly your problem and how exactly it bugs?
If you want to know how to improve the script you already got:
repeat wait() until ...
Instead doing this, I recommend just using :WaitForChild or using task.wait(x) to wait a few seconds until your part’s stuff loads.
function movePart(part)
if part...
As you already checked these before running the movePart() function, theres no need to check it again.
spawn(require(c))
This can make your code look bit confusing sometimes, so I’d recommend directly using the function and naming stuff properly.
Also, instead using spawn(), You should use task.spawn() or coroutine.wrap if you want to run the function in a seperate thread.
Often with a higher number of players in a server the parts will often not move or not be registered. Keep in mind everything is local too so it is not lag and there are also no errors.