Hey! I wanted to ask if it matters if a script is in the Workspace or in ServerScriptService. If so, what is the difference? What does each place do to the script to make it work? I’m wondering, because I combined a script that goes into the Workspace and a script that goes into ServerScriptService and I put the combined script into the ServerScriptService. I am asking because I asked a question in this post, and I think that is the problem.
ServerScriptService can’t be accessed by the client, however running server scripts in the ServerScriptService vs running them in the workspace makes no difference but you would benefit a cleaner workspace having most of your scripts in ServerScriptService.
Edit: Fixed a typo.
Yes, kind of. If you want a script to be on the server side, and it isn’t in a part or other object in the workspace, I highly recommend putting it in ServerScriptService. That way exploiters can’t see your code.
There’s no difference. A script will run the same way in workspace and in serverscriptservice. I would recommend you keep scripts in serverscriptservice because it’s just easier to access it. Also exploiters aren’t able to access server scripts in workspace. A server script is running on the server hosting the game, not on the client.
Not necessarily, but do you like any of these things?
- Proper organisation
- Less headaches accessing other code (e.g. ModuleScripts)
- Avoiding unnecessary replication of server instances to the client
- Using standard/canonical practices in your code
- Collaborating with other users (don’t have to like it, but if you are)
- Getting better at your craft by learning the right things early
If yes, then yes it does matter. Your scripts should be in ServerScriptService. An exception is coming when parallel Lua is released which then your exception is that the script may be in an Actor instance anywhere in the workspace (e.g. an NPC).
By the way exploiters can’t see server scripts regardless of where they are. Only accessible LocalScripts/ModuleScripts. I still agree it should be in ServerScriptService, since that is quite literally what it is for
It matters where the script is, it’s really important for developers to put their main scripts into ServerScriptService, why?
-
You can hide it from exploiters hacking in your game.
-
Less needing to find it on the Workspace.
-
Game can be safer, I don’t know if this is possible but you might possibly make a script that if you made it, it collects all made data on ServerScriptStorage, that deletes it automatically. (For ServerWide Hacks, etc.) It can be important, therefore the script can’t be opened and seen.
-
Yes, ServerScriptStorage hides all script to make it safe, just like a bank.