Moving Parts System help

  1. 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.

  2. 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.

I was just wondering what would be the best/reliable way to code something like this.

1 Like

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.

Didn’t you said it was a server script? Can you show me whats the function you spawning from the module?

Yea, server script will spawn part, then local script will register that part is spawned at spawn in module function.