Hello, I'm making a fighting game (JoJo Game) and in the last question I asked how do I make a cooldown script without using wait(): https://scriptinghelpers.org/questions/83011/how-do-i-make-a-cooldown-script-without-using-wait a guy said I need to use coroutines. When I added it it all worked fine and as intended but then I saw a little issue that wasn't there before I added the coroutines, When I do a couple of the same attack I just cant do the same attack anymore.

This is a part of the script:

local BarrageCooldown = false
local StrongOraCooldown = false
local BlastCooldown = false
local TimeStopCooldown = false
local StandJumpCooldown = false

local BarrageCooldownManager = coroutine.create(function()
    wait(1)
    BarrageCooldown = false
end)

local StrongOraCooldownManager = coroutine.create(function()
    wait(1.5)
    StrongOraCooldown = false
end)

local BlastCooldownManager = coroutine.create(function()
    wait(3)
    BlastCooldown = false
end)

local TimeStopCooldownManager = coroutine.create(function()
    wait(120)
    TimeStopCooldown = false
end)

local StandJumpCooldownManager = coroutine.create(function()
    wait(5)
    StandJumpCooldown = false
end)

ZZZ = Mouse.KeyDown:connect(function(key)
    if key == "t" then
        if BlastCooldown == false then
            BlastCooldown = true
            Blast()
            coroutine.resume(BlastCooldownManager)
        end
    end
    if key == "e" then 
        if BarrageCooldown == false then
            BarrageCooldown = true
            OHOra()
            coroutine.resume(BarrageCooldownManager)
        end
    end
    if key == "r" then
        if StrongOraCooldown == false then
            StrongOraCooldown = true
            StrongOra()
            coroutine.resume(StrongOraCooldownManager)
        end
    end
    if key == "f" then
        if TimeStopCooldown == false then
            TimeStopCooldown = true
            TimeStop()
            coroutine.resume(TimeStopCooldownManager)
        end
    end
    if key == "z" then
        if StandJumpCooldown == false then
            StandJumpCooldown = true
            Jump()
            coroutine.resume(StandJumpCooldownManager)
        end
    end
end)

ZZZ1 = Mouse.KeyUp:connect(function(key)
    if key == "e" then
        Stop()
    end
end)

Help Would Be Appreciated

1 comment

0

Try adding some “print coroutine.status” and see what’s running, you may also want to look into coroutine.wrap