I'm creating a combat RPG. I plan for the combat system to all be run from one main script in the workspace so that if I have to make a change, I can just edit one script instead of repeat the same changes over dozens of sub-scripts. The way the combat system will work is there will be one function for every attack in the game. On average, each function ends up being 200 lines long and I plan to have at least 100 attack moves in the game. If I continue with this approach of having one main script, there will be 100 functions in it, bringing the total number of lines above 20,000. Is this a bad idea? Will it lag my game? Is there a better way that I could handle all my attacks while still keeping it easy to make changes? If so, what could I do?
COMMUNITY QUESTION
Is it a bad idea to have a script with 20,000 lines in it on your game?
1 answer
no it isnt, unless if the first line is a
game:GetService("RunService").RenderStepped:Connect(function()
but apart from that should be fine
3 comments
0
Yes it is. RenderStepped won't do anything with 20,000 lines of code.
0
tell that to the future ppl who see this, when roblox has made RenderStepped compatible with server scripts.
0
RenderStepped won't even be compatible w/ server scripts. Its a local deal. Why would the server have access to everyones frame data?
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
It's a very bad idea. I would create a script for each individual attack and use events to trigger those attacks.
This is where ModuleScripts come in the mix.
Thank you!!
Seems interesting, doesn't it take time to switch tasks in the sheduler? So a hundred scripts vs a single script that does the same would perform differently? But then again, it's harder to manage that, unless you have an index for every function, event, and variables. Don't know if micro-micro optimizations are worth it.