Buffs and debuffs bug

I’ve been encountering an error where If I added a slowness debuff to a character and add a speed buff to the character with the same timer of being 5 seconds there will be a possible chance where the character won’t enter to it’s original speed and they will have a permenant debuff or buff to its speed

1 Like

Could you share your buff and debuff script?

1 Like

It’s just a simple function, where it just applies walkspeed to a humanoid
Something like this

function applymodifier(walkspeed,target,timer,IsDebuff)
If IsDebuff then
target.Humanoid.WalkSpeed -= walkspeed
task.wait(timer)
Target.Humanoid.WalkSpeed += walkspeed
else
target.Humanoid.WalkSpeed += walkspeed
task.wait(timer)
Target.Humanoid.WalkSpeed -= walkspeed

end

end

Srry for the late response i had to switch to a different device
Although I did heard that I should use ECS modules

1 Like

Put the buff and debuff into a thread:

function applymodifier(walkspeed,target,timer,IsDebuff)
    if IsDebuff then
        task.spawn(function()
            target.Humanoid.WalkSpeed -= walkspeed
            task.wait(timer)
            target.Humanoid.WalkSpeed = defaultWalkspeed
        end)
    else
        task.spawn(function()
            target.Humanoid.WalkSpeed += walkspeed
            task.wait(timer)
            target.Humanoid.WalkSpeed = defaultWalkspeed
        end)
    end
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.