Script Line Counter

If you are ever wondering how many lines of code your game has, try out this plugin I wrote.

I found out my game is 13000 lines of code, in total O.o

Press button, and total lines of code is output to console.


I think this could go in #learning-resources:community-tutorials-resources

Still though, this is a wonderful plugin!

1 Like

Moved, thanks!

1 Like

Here’s another plugin that does the same job, courtesy of @Crazyman32.


Was using Crazyman’s but hey, its fun to make your own plugins

Huh, didn’t know about this.

Looks like it has a nicer gui though, so use it instead!

1 Like

If you’d like to improve upon crazyman32’s plugin, you could consider adding a logical lines of code measurement.

1 Like

Well I might as well add it! SLOC is a good stat to have.

I want to rebuild the UI anyway using plugin gui.


So now might be a good time to say this:

I took some of my most used old plugins and remade them to use PluginGuis…
Which included @Crazyman32’s LoC plugin.

Rather than be selfish and keep it saved locally, I’ve just now published it.

The code inside clearly credits CrazyMan32, as does the plugin description, so I hope there’s no problem.

Edit for clarification: I didn’t just drop it into a widget, but rather I remade the GUI from scratch, and therefore had to reprogram it to work with mine. I remade the script, but the core functions were copy pasted.

1 Like

What do people use a script line counter for? I can understand a brick counter, but not a script line counter. I could certainly salvage it to see what kind of code or string patterns you’re using though.

It’s mainly for curiosity’s sake.

Lines of code doesn’t really tell you much overall though

1 Like

So you can show-off to your peers.

Since I made the plugin, here’s my reasoning:

Seeing “lines of code” (i.e. LOC) is a useful stat in terms of getting a rough understanding of a project’s size. For instance, if a project has only 300 LOC, you can guess that it’s probably a pretty simple application. However, if it has 10,000 LOC, then it’s probably pretty complex.

Another reason is that you can track code size progress. Ideally, a project should increase in code size rapidly, and slowly slow down. You should roughly see a logarithmic dropoff in code growth over a project’s lifetime.

If there isn’t a logarithmic dropoff, it might indicate something such as:

  • The underlying code is not flexible enough to allow additional features
  • Large features are still being implemented later on in a project’s life
  • etc…

One misconception is that lots of code is good. I would argue otherwise: You should try to keep your codebase as small as you can. Reuse as much as possible; don’t duplicate. Use a good framework. Allow communication between your code without major coupling. The more code you have, the harder it is to maintain.

All that being said, it can be a fun bragging point. For instance, the Curiosity Mars Rover has over 2.5 million lines of code, which is pretty cool.


Pretty incredible that they managed 2.5 million lines, especially given their incredibly stringent coding and testing standards.

Can you imagine how horrible debugging 2.5M loc must be :sweat_smile:


that must be fun!


I really like this, however, I must say that the “include duplicates” function is really not accurate. If I tell it not to include duplicates, it will remove many scripts from the count and all the code in them, despite the fact I do not have a single duplicate script in my game.

not to necro bump but you could just use:

local lines = 0

for _, v in next, game:GetDescendants() do
    if v:IsA("BaseScript") then
        lines += #v.Source:split('\n')


instead of downloading a whole plugin