ModifierManager
A type-safe stat modifier system for Roblox games.
Manage buffs, debuffs, equipment bonuses, and any numeric stat modification with
stacking rules and client synchronization.
GitHub ¡ Documentation ¡ Wally ¡ Roblox Model ¡ Example Place
Features
- Three modifier types: Additive, Multiplicative, and Override.
- Four stacking rules: Stack, Replace, Highest, Refresh. This lets you control how different modifiers from the same source interact.
- Automatic expiration: You can assign durations for modifiers, or no duration at all. Modifiers with durations clean themselves up efficiently.
- Client-server sync: PlayerManager batches stat updates and syncs to clients automatically.
- Two manager types: EntityManager for NPCs and objects, PlayerManager for players.
- Tag system: Tag modifiers for bulk queries and removal (
"buff","debuff","equipment"). - Change signals: Subscribe to stat changes for UI updates or game logic.
- Type-safe: Luau strict mode with exported types.
UI Example from the uncopylocked test place:
Quick Start
local ModifierManager = require(ReplicatedStorage.ModifierManager)
local playerStats = ModifierManager.PlayerManager.new()
playerStats:SetBase(player, "Combat.Health", 100)
playerStats:SetBase(player, "Movement.Speed", 16)
playerStats:AddModifier({
player = player,
path = "Movement.Speed",
value = 1.5,
type = "Multiplicative",
source = "SpeedBoost",
duration = 10,
})
local speed = playerStats:Get(player, "Movement.Speed") -- 24
On the client, a ClientStatReader receives synced stats and reacts to changes:
local reader = ModifierManager.ClientStatReader.new()
reader:OnChanged("Movement.Speed", function(newSpeed)
humanoid.WalkSpeed = newSpeed
end)
See the Best Practices page for a full setup with data-driven config, sync wiring, and a movement system example.
Modifier Examples
Equipment That Replaces On Swap
playerStats:AddModifier({
player = player,
path = "Combat.Damage",
value = 25,
type = "Additive",
source = "EquippedWeapon",
stackingRule = "Replace", --auto-removes previous weapon bonus
tags = { "equipment", "weapon" },
})
Stun Override
playerStats:AddModifier({
player = player,
path = "Movement.Speed",
value = 0,
type = "Override", --ignores all other speed modifiers
source = "Stun",
priority = 200,
duration = 2,
tags = { "debuff", "cc" },
})
Bulk Removal By Tag
--Cleanse: remove all debuffs from every stat at once
playerStats:RemoveAllByTag(player, "debuff")
How Calculation Works
Modifiers apply in a deterministic order:
1. Base value 100
2. + Additive modifiers 100 + 20 + 10 = 130
3. Ă Multiplicative modifiers 130 Ă 1.2 Ă 1.1 = 171.6
4. Override (if present) Uses highest-priority Override instead
5. Clamps & rounding Final bounds applied
This means a +20 Additive buff and a 1.5Ă Multiplicative buff always combine the same way regardless of what order they were added.
Stacking Rules
Control what happens when a modifier from the same source is applied again:
| Rule | What Happens | Use Case |
|---|---|---|
nil |
Accumulates freely | Default, no source checking |
"Stack" |
Accumulates (checks source) | Rage stacks, poison ticks |
"Replace" |
Removes old, adds new | Equipment swaps, aura changes |
"Highest" |
Keeps only the strongest | Shield buffs, damage reduction |
"Refresh" |
Updates value & resets timer | Refreshable buffs on reapply |
Choosing a Manager
| Manager | Key Type | Side | Use Case |
|---|---|---|---|
EntityManager |
string |
Server | NPCs, objects, world entities |
PlayerManager |
Player |
Server | Player stats with automatic client sync |
ClientStatReader |
â | Client | Read-only access to synced stats |
EntityManager and PlayerManager can only be created on the server. Use ClientStatReader on the client.
Installation
Wally
[dependencies]
ModifierManager = "estrogenie/modifier-manager@1.0.0"
Roblox Model
Get it from the Creator Store
GitHub
Clone or download from GitHub.
License
MIT, use it however you want.
Tags
modifiermanager, modifier, modifiers, stat, stats, buff, buffs, debuff, debuffs, stat system, stat manager,
modifier system, buff system, debuff system, stacking, stacking rules, additive, multiplicative, override,
equipment bonus, status effect, stat modification, stat modifier, player stats, entity stats, client sync,
server sync, replication, type-safe, luau, wally, open source, rpg, mmorpg, combat system, walkspeed, jump
power, health, damage, defense, tags, expiration, duration, temporary buff, permanent buff, crowd control,
stun, slow, speed boost, clamp, rounding, signals, onchanged, modifier manager roblox, roblox module, roblox
library, community resource
