Is it worth writing all the abilities in one script?

So I’m doing battleground in roblox where at the time of the mode will be 15 abilities and the question is:

Should I make a separate script for each ability? If yes, then there will be 30 scripts since there are 2 per ability (local and server).

Or should I make one (two) script for all abilities. But then the server script will be at least 1500 lines, which is a lot.

1 Like

I’d say use a ModuleScript to handle each ability, a ServerScript to handle what functions are called in the module, and a LocalScript to tell the server when to activate what.

Always verify parameters, cooldowns, etc. server-side to prevent exploits.

4 Likes

I would use individual ModuleScripts for each ability.

That way you can add, remove and edit them easily.

That sounds like a better idea, but only if more than one function is required for each. Otherwise, there’s no point in it being its own module really.

Yeah, I can see that.

I was just thinking of the ease of calling a ModuleScript when needed instead of using Events.

1 Like

If you didn’t found the solution yet, here is very good one:

Separate abilities into similar ability groups, like 5 functions per module, then make AbilityController, and make map that stores AbilityName → Ability Module reference

This way you can have less modules, while also have less work, of course you need to add map a lot of strings to a modules, but requiring 40 modules and requiring 5 + assigning keys isn’t that much of a difference

1 Like

What I would do is make remote events that activates a script when the local script tells it to activate the ability. I would put all these remote functions in a singular script with tables that keep track of data so it cant be manipulated by the client. There may be a better way by using module scrips so take this with a grain of salt this is just what I have done in the past. Just make sure you make comments so its easy to read since like you said it would be 1500 lines long. Personally I would rather have a big script then many scripts.

1 Like

I agree. Especially if you have to fix a bug or change something with the ability. It would be much easier then having to scroll through one huge script.

Wouldn’t that be too much code in the script or is it normal?

It depends on the script honestly. There is many situations where module scripts are good but in my opinion its also ok to use functions within the script. Its very important when you have a large script that you comment everything out so when you come back you know what you where thinking at the time. It also helps if two people are working on the same script.