# checkCooldown

```lua
function tryToUseCooldown()

    local cd_ready = helper.checkCooldown('myCd');  --works with coroutines
    --this accounts for the cd variable being from another coroutine.
    
    local cd_timeLeft = helper.cooldownTimeLeft('myCd'); --works with coroutines
    
    
    if cd_ready == false then
        log('you can\'t use this yet... until another ' .. cd_timeLeft .. ' seconds has passed');
        return;
    end
    
    log('it worked. now consume the cooldown.');
    
    helper.setCooldown('myCd'); --works with coroutines
    --set it on cooldown for the 15 seconds again...
end

myCd = {}; -- global variable;

return function()

    myCd = helper.createCooldown(16, true); 
    --create a new cooldown for 15 seconds, and it starts as ready = true
    --the name of the global variable is 
    
    tryToUseCooldown(); -- it worked!
    tryToUseCooldown(); -- can't use this yet...
    wait(16);
    tryToUseCooldown(); -- it worked!
end
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/helper-class/checkcooldown.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
