# keepAlive

```lua
--note this specific event has 2 parameters
function yourFunctionName(user, string_message)
    log(user.displayName .. ' has said ' .. string_message);
end
 
return function()
    
    --attaches the event to yourFunctionName()
    addEvent('chatMessage', 'yourFunctionName'); 
    
    --make sure this script is kept alive so the event can be processed!
    keepAlive();
    
    --nothing below keepAlive() will ever be reached.
end
```

{% hint style="info" %}
keepAlive(); is often used with scripts that are set to Run as "On Connect" and scripts that subscribe to specific events.
{% endhint %}

{% content-ref url="/pages/iqU0qDpy3WUjGbyDLU4V" %}
[Events](/lua-scripting-api/api-reference-and-tips/events.md)
{% endcontent-ref %}


---

# 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/global-functions/keepalive.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.
