#Combat system combo issue

1 messages · Page 1 of 1 (latest)

whole umbra
#

So my current issue is the combo is giving me an extra attack even though the max combo is 5,


local function PlayAnimations(hum, count)
            local currentAnimation = count
            local currentAnim = WeaponAnimations.DefaultLSAnims.Combat["Swing"..currentAnimation]
            local animation = hum.Animator:LoadAnimation(currentAnim)
            animation:Play()
        end```  Animation code 



function module.ChangeCombo(char)
local combo = char:GetAttribute("Combo")

if lastSwing[char] then
    local passedTime = tick() - lastSwing[char]
 if passedTime <= 2 then
        if combo >= MaxCombo then
            char:SetAttribute("Combo",1)
        else
            char:SetAttribute("Combo", combo + 1)
        end
    else
        char:SetAttribute("Combo",1)
     end
end
print("Combo / "..combo)
lastSwing[char] = tick()

end```

tender skiff
#

where is maxcombo defined at

chrome gust
whole umbra
whole umbra
#

Idk if that’s the issue though

ionic bane
# whole umbra So my current issue is the combo is giving me an extra attack even though the ma...

hello, try this:

function module.ChangeCombo(char)
    local combo = char:GetAttribute("Combo")
    
    if lastSwing[char] then
        local passedTime = tick() - lastSwing[char]
     if passedTime <= 2 then
            if combo > MaxCombo then --changed >= to >
                char:SetAttribute("Combo",1)
            else
                char:SetAttribute("Combo", combo + 1)
            end
        else
            char:SetAttribute("Combo",1)
         end
    end
    print("Combo / "..combo)
    lastSwing[char] = tick()
end

changed combo >= MaxCombo to combo > MaxCombo, might work 🙏

#

i changed it to > because even with how you have it currently (using >=),
if combo's value is 5, then combo >= maxcombo would still run, adding 1 more to your combo value, making it 6
however, if we use >, then it wouldn't add 1 to your combo if the value is 5 anymore, it only run if the combo value is 4 or below, capping your combo at 5

keen pivotBOT
#

studio** You are now Level 1! **studio

whole umbra
#

I was able to fix it !