Alright, first you will want to benchmark your system as it is right now. Here’s a handy community tutorial I found. However, it’s not that useful for actually optimizing your code.
Because I don’t actually have the time right now to write out an explanation and relevant code samples, I’m just going to post a list of links you can check out. Hopefully you’ll find some, if not all, useful. The first link will most likely be the most helpful.
On this one, ignore the part about testing the speed of your code. You should use os.clock instead of tick for unit test and benchmarking.
This tutorial is by @Hexcede. He knows a lot about Roblox’s engine (or at least a lot more than me) so I would really try to understand it. Also, you’ve probably noticed that I’ve posted a few tutorial links for networking and reducing latency. This is because you might run into it later when developing your system.