#Combo reset doesnt work

1 messages · Page 1 of 1 (latest)

hasty hearth
#

So I made a punch system where you have a combo of 4 attacks and at the 4th its resets it resets also if I dont attack for 2.8 secounds the problem is its still reseting if I do the first punch right before it I add a video the numbers in the output is the combo I have and it prints combo reset if the combo resets

--//--change Combo--//--
local function resetCombo(char)
    local currendcombo = char:GetAttribute("combo")
    wait(2.8)
    if char:GetAttribute("combo") == currendcombo then
        print("combo reset")
        char:SetAttribute("combo", 1)
    end
end 

local function changeCombo(char)
    if char:GetAttribute("combo") < 4 then
        char:SetAttribute("combo", char:GetAttribute("combo") + 1)
    elseif char:GetAttribute("combo") == 4 then
        char:SetAttribute("combo", 1)
    end
    task.spawn(function()
        resetCombo(char) 
    end)
end
``` this is the funtion to change the combo after an punch so it just makes the attribute in the plr one higher and plays the combo reset thing after it to see if the combo gets reset
hasty hearth
#
module.normalPunch = function (char,hum)

    COMBO = char:GetAttribute("combo")
    print(COMBO)
    changeCombo(char)

    task.spawn(function () sh.jump(char,0.6) end)
    
    local newHitbox, connected = HitboxClass.new(hitboxParams)
    
    local hits = {}
    newHitbox.HitSomeone:Connect(function(hitchars)
        for m,i in hitchars do
            local echar = hitchars[m]
            local eHum = echar.Humanoid
            
            if echar == char then return end
            if echar.IsRagdoll.Value == true then return end
            if eHum.Health == 0 then return end

            hits[#hits+1] = eHum
            PlayHitAnim(eHum)

            sound(script.Phit,echar.HumanoidRootPart)

            eHum:TakeDamage(3)
            pushForce(char,echar,7)

            for _,i in hits do
                if i then
                    if game.Players:GetPlayerFromCharacter(char):DistanceFromCharacter(echar.HumanoidRootPart.Position) >= 5.5 then
                        pullForce(char,echar,12)
                    elseif game.Players:GetPlayerFromCharacter(char):DistanceFromCharacter(echar.HumanoidRootPart.Position) >= 1.5 then
                        pullForce(char,echar,7)
                    end
                end
            end

            task.spawn(function() sh.stunned(echar,1) end)
        end
    end)
    
    HitboxClass.WeldTo(newHitbox,char.HumanoidRootPart,CFrame.new(0,0,-2))
    newHitbox:Start()
    wait(0.4)
    newHitbox:Stop()
end
#

this is the script where i punch

#

I think it only happens if the enemy is ragdolled so if the IsRagdoll value of the enemy is true

#

but Im not sure wh

#

y

void radish
#

might be because of the wait 2.8 thing

#

after 4th punch it waits 2.8 seconds which is approximately after you hit the first punch

#

the reason being is currendcombo is always 1 when it ends, not 4

#

which makes the

if char:GetAttribute("combo") == currendcombo then

true

#

(currendcombo is always 4 at the end because it gets set to 1 first then it fires resetCombo)

hasty hearth
void radish
hasty hearth
hasty hearth
#

yea

#

so how would I fix that

void radish
#

and remove the one nested on task spawn

#

then add another after char:SetAttribute("combo", char:GetAttribute("combo") + 1)

#

theres probably a better way to do this im just too lazy to think bout it