# split

```lua
function yourEvent(user, string_message)

    local words = helper.split(string_message, ' '); 
    --this is extremely helpful for bots that are trying to read commands!
    --split the message on spaces to get words in an array
    
    --check the first word
    if words[1] ~= '!yourCommand' then --in LUA... arrays start at index 1, not 0!
        
        --if word[1] is not equal to your command, exit.
        yieldBreak();
    end
    
    if words[2] == 'start' then
        log('the user has typed: !yourCommand start');
    end
end

return function()
    addEvent('chatMessage', 'yourEvent'); --attaches the event to yourEvent()
    keepAlive();
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/split.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.
