#Attack Looping Forever

1 messages · Page 1 of 1 (latest)

misty rover
#

I had a module set up to do an attack combo while the button is held. It was working well a few days ago where spam-clicking and/or holding would respect the cooldown in between each hit in the combo, and letting go of the mouse would stop it. Now, though, it's broken, and just loops forever. I'm having some trouble figuring out how to fix it, hopefully it's not too much to ask for any ideas on how to fix it, since I know it already wasn't great code but it at least worked for a bit haha.

Code Below:

    Step = 1, Started = false, Timer = {Value = tick(), MaxWait = 1.2},
    Data = {
        {Damage = 12, Cooldown = 0.5},
        {Damage = 12, Cooldown = 0.5},
        {Damage =  8, Cooldown = 0.5},
        {Damage = 24, Cooldown = 0.8}
    }
}
---------------------------------------------------------------------------------------------
local Light = setmetatable({}, AbilityClass) :: AbilityClass.Ability
Light.__index = Light

function Light.New()
    return setmetatable(AbilityClass.New("Light"), Light)
end

function Light:Execute(plr, actionName, inputState, inputObject)
    Combo.Started = inputState == Enum.UserInputState.Begin and self.State == "Ready"

    while Combo.Started do
        self.State = "Active"
        if tick() - Combo.Timer.Value >= Combo.Timer.MaxWait then Combo.Step = 1 end -- Reset

        -- Hitbox
        CreateHitbox:InvokeServer(Combo.Data[Combo.Step].Damage, Vector3.new(5, 7, 5))
        self.Cooldown = Combo.Data[Combo.Step].Cooldown
        self:doCooldown()
        
        -- Reset
        if Combo.Step >= #Combo.Data then Combo.Step = 1
        else Combo.Step += 1 end
        Combo.Timer.Value = tick()
    end
end

return Light```
misty rover
deep burrow
misty rover
#

do you need me to send a friend request so I can dm you, is what I meant