What should be done on server script and what should be done on local script

Hello, i already know the difference between these two scripts however my question is what should be done on server script and what should be done on local script for example loading a animation in a local script or a server script

do any player/client related tasks such as ui updating or animation handling on a local script

anything that has to do with the actual game in places like workspace or serverstorage, you should use serverscripts

It depends. Loading animations is usually done on local scripts, however if you want to load animations for an NPC, a server script should be used if you want everyone in the server to see that animation, local script if you don’t want that. Local scripts run on the client so most things that are done on the client can’t be seen by others. Local scripts can fire events though, which when received by a server script can make things happen that everyone can see! This concept doesn’t only apply to visible things though, it also applies to values and stuff like that. Now to list some things you can do with local scripts and server scripts:

  1. Display player stats in a gui
  2. Show certain visual effects (Can also be done on the server)
  3. Playing animations

One thing you should NEVER do is have events that increase the players points or something like that. Exploiters can also fire events, so they could just spam that and get infinite points! You should try and do stuff like that on the server without the need of events! Now here are some things you could do on the server:

  1. Storing the players data
  2. Handling player data (like points)
  3. Special abilities

For special abilities, an event is necessary, however you can avoid having exploiters spam your abilities! Instead of counting the cooldown on the client, you should also count it on the server. What I recommend doing is:

  1. For each player that used an ability, add them to an array.
  2. Make a coroutine that waits for x amount of seconds and then removes them from the array

you can simply check if the player is in the array, and if he isn’t, then you can do the ability.

There is one other type of script, a module script. It’s just a script that stores functions/data that you can request on both the client and the server, useful for VFX.

I don’t really have anything else to say, but I hope you get the idea.

5 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.