Hi developers, I am having a major issue with my status effect module which I made. It’s not easy to explain the problem in detail and have it make sense, so I’ll link a video (ignore 3 fps my computer is bad)
Watch 2025-03-23 16-23-30 | Streamable
The problem is clear. Whenever I attack another character, the status effect transfers into that new one and doesn’t stay in the old one. Infact, it even stacks onto the new character. This is not intended behavior. The intended behavior is for the status effect to stay on the character until it ends or is destroyed via manual means.
Context:
local function startEffect(effect: EffectModule)
effect.Character=self.Character
effect.Destroyed = Signal.new()
table.insert(self.Effects, effect)
local thread = task.defer(effect.OnStart, effect)
local event: RBXScriptConnection
effect.Destroyed:Once(function()
if effect.OnStop then
effect:OnStop()
end
event:Disconnect()
task.cancel(thread)
end)
event = RunService.PostSimulation:Connect(function()
if coroutine.status(thread) == "dead" then
effect.Destroyed:Fire()
end
end)
function effect:Destroy()
effect.Destroyed:Fire()
end
end
self.EffectAdded:Connect(function(effect: EffectModule)
startEffect(effect)
end)
function self:AddEffect(effect: EffectModule)
self.EffectAdded:Fire(effect)
end
There was only one solution I could find to this, and that was this:
local newEffect = {}
for k, v in (requireEffect) do
newEffect[k] = v
end
newEffect.Character = self.Character
self.EffectAdded:Fire(newEffect)
It works, but there is another problem. I want to be able to find how much of an effect that a character has applied to them, which I can’t do when creating a new table and assigning every key to a value in the effect module.
if #statusChar.GetAllEffectFromParams(burnStatus)==0 then
statusChar:AddEffect(burnStatus)
end
Is there any way to solve this issue?