Any tips on organizing scripts?

So I wanna know how I can make sure my scripts aren’t a bunch of nonsense, ugly code,
lazy code, placed the wrong places on the Explorer and all the bad things which you can do.

I’m not sure how I’ll have to do it, but I think it’s a great idea to have some tips from developers who are more experienced.

I’ve looked around for videos on how to organize scripts, but I feel like I need some more information.

I hope to get some amazing tips :slight_smile:


A bunch of tips:

  • Make sure you’re indenting is correct, indenting is putting tabs tab before each line depending on its scope, which makes things more beauiftul and understandable
--indented code, beautiful
while true do
    if true then
--not indented, ew
while true do
if true then
  • Good variable naming, there are multiple ways to name variables
local VAR_NAME --all upper case
local varName --camel case
local VarName --pascal case

local varname --this looks bad

Also make sure the name are comprehensible, and don’t contain a lot of number and weird characters


Not sure if this is the wrong word, but avoid coupling at all costs.

When I was making a game, I had a lot of major issues with that. For instance, a game functionality that dictated something else, was inside of another game functionality.

I had a leaderboard mechanic that was also controlling the areas in which players are allowed to attack. If you design your game like this, you are going to have major problems down the line.

1 Like


I’m doing Indented Coding,
Starting to use Variables with Starting Upper Cases.

Do you have an example of what you mean by
Avoiding Coupling?

Good, it is also a great idea to vary between usages of names, for example, for important variables you can do VARIABLE but for something normal do variableName


Yes, I gave an example of an issue a game I was working on had.

In that scenario, the proper thing to do was to separate the scripts.

1 Like

Oh now It gave sense haha,

So you had 1 script with 2 different mechanics?
Which isn’t a good idea to have.

Yep, and another thing to learn about functions is that they should only be doing one thing and one thing only.

If you have a function called “getResultOfEquation” it should do exactly that, return the result of whatever equation you give it.

1 Like

What I would do is what starmax did, and other things that I would do is add commentaries, for example:

print(x) --Debug code

Another example:

local SerStorage = game:GetService("ServerStorage")

And lastly, add information about the script:

--//Created by Conejin_Alt//--
--//11:46AM UTC 10/10/20//--
--//This code is used for something cool//--

I hope this helps.


I just categorize them like this:

-- Name: Name.Lua
-- Written by Name
-- Use: Use of the script


@DaffyDavinko @Conejin_Alt I would disagree on putting your name and date and such at the top of the script. This only bloats the script and doesn’t add anything useful. Like who cares that I write a script at 3:52 PM that doesn’t contribute to my development. It’s obvious who wrote it, though @DaffyDavinko explaining the script’s purpose is a good idea.

1 Like

Use modules and functions more often to organize code. It makes it neater, sectioned off, and easy to reuse.

local Var
local VarTrue
local Var1
local VarHello
    print("I like organize")
*Insert other things here

Basically do that,i honestly dont do,but you are asking on how you would do it,so ye,keep putting those


I would just recommend you to keep all your server scripts in ServerScriptsService as that keeps them organized, have a different name that’s simply describing the script and is easy to remember for all of your scripts in case you want to check them out later on, and just try and keep all the scripts together, for example, they could be in a Folder and not just everywhere, that will help organize it a little bit in Explorer.


We have different opinions.

By the way, this would work if you make an open sourced game, anybody who needs help on the script, he could see the name written in the script and message him for help.

Writing the date is useful too, to see if you have something outdated, for example, if print is replaced to Print at 3PM, if you go to your script, you might find that your script was updated at 2PM, and you can replace print to Print.

Writing information about your script is very important, if you are lost and you forgot what the script does, or if you give your game to another person, you can read the script information.

Big developers are doing this practice too, I think this is useful, commentaries are made for that reason. Give information.