My script exceeded 5000 lines, is it going to break?

So I’m continuing work on my UI module script and I noticed that it exceeded 5000 lines:

image

(The purpose of the script, if you’re wondering, contains functions for dialouge, custom proximity prompts, etc. Its a bit of an all rounder.)

At first I celebrated on the inside a little bit, but then I realised two things:

A: I could do this more efficiently. (Thats a me problem)
B: Wait, will my script break now?

You may ask: why would a script break when going over 5000 lines?
Well, in the roblox studio settings you can find this:

image

image

I guess the question I’m trying to ask would be does this ‘Large File Line Count Threshold’ actually affect my scripts when I go over the limit?

And, if you happen to know a lot about this setting, what language features are they talking about and how important are they?

3 Likes

Nope.

Execution speed won’t be affected, but if you’re doing everything in your script serially (eg, run line 1, then 2, then 3…), it may take a while before you reach the end of the script.

For scale, some of the big games (that I will not name) have, or used to have, somewhere about 200,000 lines of code in a single script.

It won’t, it just affects your experience with WRITING the script.

  • Syntax highlighting (local and function is no longer displayed in red, etc.).
  • Linting (the red or orange underlines you see when you make a mistake in your code).
  • No linting also means goodbye to typechecking if strict typing is what you’re into.

If it weren’t for intellisense, this makes it no better than writing your code on Notepad.

You have nothing to worry about here. Carry on.

2 Likes

Oh, to add on something important:

Scripts do have a limit of 200 local variables and functions (upvalues). Keep that in mind.
Likewise for functions - 200 local variables per function, not shared with the script’s upvalues limit, or preceding functions’ limits (if you’re nesting functions within functions).

Also, ultimately you should make your script READABLE. Read up on techniques on how to shorten your scripts for brevity.

1 Like

Thats just great. I was going to keep all of my functions in one script but now I guess I have to break them up anyway? I’m hesistant because I swear I read somewhere that requiring multiple module scripts slows down a script, is that true?

That is false - at least not in the way you think. I’d almost find this fact misleading.

  • Requiring modules really don’t take as long as you think it does. If it did, most games would have a problem with load times. There are games that have massive libraries containing an obscene amount of modules, imagine that.

  • Typically you’d require modules only at the beginning of a script’s lifetime - which is also the time which a player first joins, and your game first loads in. As long as you’re not repeatedly requiring a module, you’re fine.

1 Like

Auto-fill is also gonna be a lot slower.

Not exactly. Intellisense isn’t affected by that feature per say, since that doesn’t rely on reading through every single character in your script for it to work - unlike linting and highlighting.

If it does slow down, it’s simply because of the sheer amount of text your system has to keep in memory and display to you - but then at that point, you must have a really outdated system, your script is just that massive, or your settings are messed up.

You’d have bigger problems than a slow IDE if that were the case.

Well in my case, autofilling in a very large script has always been slow for me, even showing certain methods and classes like Enum as a suggestion.

I forgot to add on; this also includes adding/removing new characters in your script, both of which must be done if you rely on intellisense. It’s not intellisense’s fault on its own, it’s just that your system just can’t keep up with all those characters.

You may want a new PC for that - but then: can it run Crysis? /j

Unironically might be that.
image

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