Are local scripts a good way to optimize your game?

Local scripts run entirely client-side. Server scripts, aka “scripts”, run entirely server-side. Server scripts should be used to manage the state of the game and all the players. The server is one single machine that controls what happens for everyone. Anything the client does that other clients may see must be validated server-side, as it’s the only machine you can actually trust. There is no performance to be gained from switching over to local scripts. Anything that the client visually sees, aside from objects in workspace, should be controlled via local script. Anything the client should not be able to modify without requesting modification from the server should be run via server script.

To add on to what @Avigant said, computing on the client rather than offloading all the work to the server will definitely improve server performance. Most clients’ machines are more than powerful enough to perform their own computation, but if we just offload it to the server, the server then needs to compute for itself and every other client. Essentially, if we have 10 players in the game, the server would be using more than 10x the resources a single client’s machine would be using if it computed a result on its own, as the server would need to compute 10 different results based on data from 10 different clients.

For more information on the client/server model, see here.

8 Likes