Ways to reduce script lag?

Hello, I currently have a script with roughly 5,500 lines and I have noticed that the typing time and the overall script editing time is getting longer and longer as the line numbers increase. Is there any way I can do something to reduce the lag when typing so I can continue typing fast? For instance maybe closing some of the tabs on the side bar where I am not editing certain functions?

1 Like

You can write your functions in modules if it’s not a local scripts to separate lines. I never experienced lag from scripting tho.

My script is a local script. Here is an example of what I mean:

It started doing this as my script got longer and longer and it is starting to get to the point where I am concerned because I still have a lot that I need to add to it.

Other people and I have similar problems and this is after the most recent studio update.

I get that more lines would cause it to lag more… but it is lagging me with just a few hundred lines.

Well, since there is a really heavy load on your CPU, it might not keep up. Correct me if I am wrong, but I think the amount of RAM you have depends on this too, to store all the lines in a cache.

Use an external roblox lua script editor because the default one is not really optimized for such long code!

Well from my experience, if your script is longer than 1k lines then you must be doing something wrong, unless you chose to cram multiple scripts into one.

Are you repeating code?
If so then maybe create a function for that code.

Do you have too many numbers? This on is a bit rare
Maybe use IntValue to store the data.

Do you have lots of while true loops?
This I suggest using corotines (dont know how to spell it)

2 Likes

Mind sharing some examples of those external roblox lua script editors??

1 Like

Visual studio code or sublime text for example!

2 Likes

For example Visual Studio Code, with Rojo to sync the code to studio. You should definitely look into modulescripts, you shouldn’t need a 5k+ line script. How do you stay organized with everything in one script?

1 Like

So I can download Visual Studio code, copy and paste everything from my localScript there and then use rojo to sync it all back in?

You should be able to use rbxlx-to-rojo to convert the place into a rojo project. But you should definitely use modulescripts. If you are going to use vscode I’d recommend downloading the extensions TabNine, Bracket Pair Colorizer and Roblox LSP.

Just to let you know and I don’t know if this problem affects your script editor, script editor is having a lag problem recently, as you can see.
And if your script getting delayed from yesterday/today, this might be a problem.
But I really don’t know.