How do you organize your scripts?

I’m new to Roblox development, and I want to get into habits that other developers are using.

I’m between putting scripts into or near the objects they interact with, or putting everything under SeverScriptService. Obviously, LocalScripts will go into the Player’s folder.

How do you organize your scripts?

Thanks for any replies!

1 Like

What I usually do for frameworks is use a modular approach. (OOP, classes, and whatnot)

However, for a beginner, I would probably go for the ServerScriptService approach. However, you don’t want hundreds of scripts in ServerScriptService in random spots. I would use folders to organize them. Combine scripts if possible AND REASONABLE.

1 Like

Also, make sure to utilize for loops and tables to prevent having to add a TON of scripts that do essentially the same thing. I keep seeing beginners make this mistake for some reason.

1 Like

I usually do this:

Modules

Most of my modules go in ReplicatedStorage, under a folder named Dependencies.
Modules which can be used both by the server and client go in that.
Server-Only and Client-Only modules go in their respective directories under the Dependencies.
image

ServerScripts

For server scripts, I tend to place them all in ServerScriptService.
I use CollectionService to handle instances with a tag attached to them + a type to define the general structure of objects is pretty handy and efficient.

PlayerScripts/LocalScripts

For LocalScripts, I place them where I think they would make more sense.
For a Custom Character or a Camera Controller, I’d use StarterPlayerScripts.
For stuff that involves the player’s character, right into StarterCharacterScripts.
For Gui, I think you know where it best belongs.

Again, this is my way of organizing code and scripts. You can adopt this way of organizing, or take inspiration from it and develop your own way of organizing code and scripts (How many times have I said organizing holy)

4 Likes

Just another addon as to why there are folders named lib and modules.
lib is for external modules/libraries from other authors/developers, such as Lux, Janitor, Iter (shameless plug) and AIEngine.
modules is for user-defined modules.

3 Likes

I think I will take this approach!

Also, make sure to utilize for loops and tables to prevent having to add a TON of scripts that do essentially the same thing.

I have experience in other languages, so I definitely will do all of that! I like how many built-in functions there are, it’s pretty nice.

1 Like

Thank you! I think I’m going to steal this exact approach :grin:

1 Like