My Code Will Be Too Long, Any Fixes?

I am making a minigame type game. The support I need is that the script i am making is going to be VERY long! I will have to make an event for every event that could happen. Let’s say I had an explosion gamemode and a missile gamemode. I will have to write what the whole explosion gamemode does, then after that I will have to write the missile gamemode, probably taking up around 20 lines each. What if i had 30 gamemodes? if all of them are around 20 lines each, I will have 600 lines of code! Is there any way to shorten a code like this? I will edit this once i make the code as an example.

Edit: What I mean by shorten is by storing what the gamemode does in a separate script.

Also, if i used this topic wrong, I am sorry, I am quite new to the devforum so expect some mistakes!

1 Like

I mean you could have a module script somewhere where you can access it wherever needed providing the explanation of each mode.

1 Like

I will give it a try and mark you as the solution if it works!

2 Likes

I mean if you have a dictionary in that module explaining each mode it should be fine. Give it a go and good luck.

2 Likes

Make a module that has all of the gamemodes, the module will have logically a long code but in the main script you will only have to call the function.

2 Likes

Thanks! Boston also suggested that so I am going to try it.

1 Like

I suggest using modules for functions etc. If your loading game modes you can have modules have the game mode information like the map name, round time and more.

If your new to modules here’s some information. there very simple
https://developer.roblox.com/en-us/api-reference/class/ModuleScript