Best way to organize Buffs/Debuffs without duplicating inverses?

Hello,

I’m trying to figure out a clean way to organize buffs and debuffs in Roblox.

Some effects are unique (like Stun or Poison), so it makes sense to give them their own ModuleScript.
But other effects are basically just stat modifiers — for example:

  • CritChanceUp vs CritChanceDown
  • SpeedUp vs Slow
  • DefenseUp vs DefenseDown

These are almost identical in logic, just one increases a stat and the other decreases it.

If I make a separate ModuleScript for every single one, the folders get bloated and full of repetitive modules (one for the buff, one for the debuff).

Like if i create one module script that handles the stat changing , it won’t benefit me since the name of these effects (if we consider these generic stat changers as effect) are necessary, it goes like this

A player activates an ability → server does the functions of the ability and after that it looks for any buffs/debuffs on it and apply it → activate the module of the effect

Why not assign the stat a value to determine it’s effect? For example, the effect is simply called “Defense” and a positive value means Up and negative means Down.

the problem is these effects are temporary , for example i have a function that will check the deubuff like the stunn effect and apply it , now this is what i want untill i faced these defense up/down problem, if i do as you say the template of each ability won’t be the same as the ones that have the unique abilities

You can always return the effect’s magnitude and then when you call the effect you check if it returned any magnitude, no? That way you can call the same function but be able to tell between a generic and unique effect

I’d recommend using an ECS module like Jecs where you can do stuff like pair(StatusEffect, Buff/Debuff/Unique), not only does this make your condition much better it makes composition easier for.. basically everything else. Recently i’ve been structuring my games entirely around ecs and its been much easier to create new things out of existing components!

Only downside is that it’s quite different from OOP and you do have to learn how to use the ECS module of your choice (whether that be Jecs, Matter, ECR, etc), but once you get the hang of it it’s great.

can we discuss in private about it ?

1 Like

it is more about organizing then this
like i can make abilities whp have unique effect linked to a folder that has these modules and it does it logic
but what about generic ones do i need to create a generic logic for each one , it seems messy tbh, i have been trying for looking for a way to make it in a module script but i havent find any yet