#move cancelling

1 messages · Page 1 of 1 (latest)

silver folio
#

this is for ability cancelling

how would i go about cancelling a move (while its running) from the outside?
ive used coroutines and task.spawn, but im trying to get a jjs effect where the function yields and THEN the function returns the cooldown

my utility script:

module.RegisterMove = function(info)
    local Player = info.Player
    local Function_ = info.Function

    if not Player or not Function_ then
        return 0
    end

    if Moves[Player] then
        module.CancelMove({Player = Player})
    end

    local PlayerFunc = Function_(info.Sending or {})
    if not PlayerFunc.Move then
        return 0
    end

    local cooldown = PlayerFunc.Move()

    Moves[Player] = {
        Move = info.MoveName,
        Cooldown = cooldown or PlayerFunc.Cooldown or 0
    }

    return Moves[Player].Cooldown
end

an example function:

module["YOU FOOL!"] = function(info)
    local function move()
        info.Player:SetAttribute("CanAttack", false)
        print("you fool!!!")
        wait(5)
        print("done")
        info.Player:SetAttribute("CanAttack", true)
        return 65
    end

    return {Move = move}
end
jolly aurora
#

which is using coroutine.cancel

#

i dont really use this method since its not really reliable for me just a personal oppinion

#

second way is instead of task.wait you use a loop to check if player is attacked then cancel the attack function

cold dagger
#

No

#

Just use a while loop

#

Trust me 🙏

cold dagger
#

I spent my whole life doing abilities 💔

#

Normally you would just stop the animation, then in your ability script have an ability.Stopped or .Ended and check whether it's prematurely stopped or what then do the cd and cleanup

clear spoke
#

There is a library called Promise that someone made, it might be helpful in your case

#

Let’s you easily handle coroutines

silver folio
#

ive figured it out, instead of making a system that automatically handles the cooldown, i could just make a function that sends a cooldown when its cancelleld or finished