> For the complete documentation index, see [llms.txt](https://docs.streamavatars.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/events/on-avatar-spawn.md).

# On Avatar Spawn

<pre class="language-lua"><code class="lang-lua">function yourEvent(user)
<strong>    log(user.displayName .. ' has spawned!');
</strong>end

return function()
    addEvent('spawn', 'yourEvent'); --attaches the event to yourEvent()
    keepAlive();
end
</code></pre>

{% hint style="info" %}
Events are asynchronous coroutines.
{% endhint %}
