# onClientDebugMessage (Client)

> Fired on this client for every script line that goes to the log: errors, warnings and messages.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Event
- **Side**: Client
- **Category**: Output and debugging
- **Cancellable**: `cancelEvent`
- **URL**: https://wiki.mymp.gg/en/onClientDebugMessage

## Syntax

```lua
addEventHandler("onClientDebugMessage", root, function(string message, int level, string|nil file, int|nil line) ... end)
```

## Handler parameters

| Name | Type | Description |
| --- | --- | --- |
| `message` | `string` | The line's text. |
| `level` | `int` | `1` error, `2` warning, `3` message (from `outputDebugString` with another level, `print` or `outputServerLog`). |
| `file` | `string\|nil` | The file the line came from, or the resource's name. `nil` for messages. |
| `line` | `int\|nil` | The line in the file. `nil` when unknown. |

## Source

The root element (`root`).

Cancelling the event keeps the line from being written. What a handler of this event writes does not fire the event again.

## Example

```lua
addEventHandler("onClientDebugMessage", root, function(message, level, file, line)
    if level == 1 then
        triggerServerEvent("onClientScriptError", resourceRoot, message, file, line)
    end
end)
```

## See also

- [onDebugMessage (Server)](https://wiki.mymp.gg/en/onDebugMessage.md): Fired on the server for every script line that goes to the log: errors, warnings and messages.
- [outputDebugString (Shared)](https://wiki.mymp.gg/en/outputDebugString.md): Writes a line to this side's script log, as an error, a warning or a message.
- [print (Shared)](https://wiki.mymp.gg/en/print.md): Writes the values given to the script log as a message, separated by tabs.
