> For the complete documentation index, see [llms.txt](https://tgiann.gitbook.io/tgiann/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tgiann.gitbook.io/tgiann/common-errors/how-to-find-and-fix-script-errors.md).

# How to Find and Fix Script Errors

Where to look in the server console, how to read an error and how to fix it, even if you do not know how to code.

Almost every script problem leaves a message in the server console, and that message usually tells you what is wrong. This page shows where to find it and how to read it.

## Errors usually show up when the script starts

A script rarely breaks while players are using it. It usually fails the moment it starts. The most common cause is a file that got broken while it was being edited: a missing `}`, `,`, `end` or `"` in a config file is enough.

When a file is broken, the script prints the error as soon as it starts and tells you which file and which line is wrong:

```
[ script:tgiann-xxx] Error parsing script @tgiann-xxx/configs/config.lua in resource tgiann-xxx: @tgiann-xxx/configs/config.lua:42: '}' expected (to close '{' at line 10) near 'label'
[ script:tgiann-xxx] Failed to load script configs/config.lua.
```

Read it like this: in `configs/config.lua`, on line 42, a `}` is missing for the `{` opened on line 10.

{% hint style="info" %}
Did the error appear right after you edited a file? Undo your last change, or compare the file with the original one from your download, and look at the line the error names.
{% endhint %}

## The last line in the console is not always the error

The server keeps printing after a script fails, so the real error is often far above the bottom of the console. Errors that happen at startup are printed at the moment the script starts, between the other scripts' start lines.

To find them:

1. Open the **Live Console** in txAdmin.
2. Scroll up slowly, from the bottom to the top.
3. Look for the script's name and read the lines around `Started resource <script name>`.

{% hint style="success" %}
Shortcut: type `restart <script name>` in the console. The script starts again and its startup errors are now printed at the bottom. Do this on a test server or when few players are online, because restarting a script can affect players who are using it.
{% endhint %}

## Not every error is red

Many errors are red, but some are yellow and some are plain white or grey text. Do not skip a line because of its color. Read the white lines near the script's start too, especially lines with words like `error`, `failed`, `could not`, `missing`, `not found`, `warning` or `update required`.

## The error often tells you the fix

Most errors can be read like a sentence and already say what to do. For example, when a script needs a newer tgiann-core, the console prints:

```
Update required for tgiann-core script (current version: 4.80.0) (minimum version required: 4.90.0)
```

The fix is written in the message: update tgiann-core to 4.90.0 or newer.

Some common messages:

| Message                                                        | What it means                                                                                                   | Fix                                                                                                                                                                                     |
| -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Update required for <script> script`                          | A script this one needs is too old.                                                                             | Update the script named in the message.                                                                                                                                                 |
| `Could not find dependency <name> for resource <script>`       | A required script is missing or its folder name is different.                                                   | Download the missing script and keep its folder name exactly as written in the message.                                                                                                 |
| `Couldn't find resource <script>`                              | The server cannot find the folder.                                                                              | Check the folder name and make sure it is inside your `resources` folder.                                                                                                               |
| `Error parsing script` / `Failed to load script`               | A file is broken, or the server artifact is too old.                                                            | Fix the line the error names. See [Error parsing script / Failed to load script](https://tgiann.gitbook.io/tgiann/common-errors/error-parsing-script-failed-to-load-script.md).         |
| `syntax error near '<\1>'`                                     | The files were damaged while uploading.                                                                         | See [Error: syntax error near '<\1>'](https://tgiann.gitbook.io/tgiann/common-errors/error-syntax-error-near-less-than-1-greater-than.md).                                              |
| `You lack the required entitlement`                            | The server's license key does not own the script.                                                               | See [You lack the required entitlement to use tgiann-\*](https://tgiann.gitbook.io/tgiann/common-errors/you-lack-the-required-entitlement-to-use-tgiann.md).                            |
| `Failed to verify protected resource`                          | The escrowed files could not be checked.                                                                        | See [Failed to verify protected resource](https://tgiann.gitbook.io/tgiann/common-errors/failed-to-verify-protected-resource.md).                                                       |
| `attempt to call a nil value` / `attempt to index a nil value` | The script expected something that does not exist (a missing export, an outdated script, a wrong config entry). | Read the file and line in the message. See [SCRIPT ERROR: ? attempt to call a nil value](https://tgiann.gitbook.io/tgiann/common-errors/script-error-1-attempt-to-call-a-nil-value.md). |

## Start order and dependencies

Scripts must start after the scripts they need (for example oxmysql, ox\_lib, your framework and tgiann-core). The order of the `ensure` lines in `server.cfg` sets this order.

But a script written at the bottom of `server.cfg` does not always start last. If another script lists it under `dependencies` in its `fxmanifest.lua`, the server starts it earlier, at the moment that other script starts:

```lua
-- fxmanifest.lua of tgiann-xxx
dependencies {
    'oxmysql',
    'ox_lib',
    'tgiann-core',
}
```

Here, even if `ensure tgiann-core` is the last line of `server.cfg`, tgiann-core starts as soon as tgiann-xxx starts. If tgiann-core needs your framework and the framework has not started yet, tgiann-core starts too early and prints errors.

Every script prints `Started resource <script name>` when it starts, so the console shows the real start order. Read these lines from the top and check that each script starts after the scripts it needs.

## Errors in the game (F8)

Some errors only happen in the player's game (menus, UI, client scripts) and do not show in the server console. Press `F8` in game to open the client console and read it the same way.

## Use an AI if you do not know how to code

You do not need to know Lua to understand an error. AI tools like ChatGPT, Claude or Gemini can explain what an error means and often fix it:

1. Copy the full error, including the lines under it that start with `>`.
2. Copy the file the error names, or at least the lines around the line number.
3. Paste both into the AI and ask what the error means and how to fix it.

{% hint style="warning" %}
Never paste your license key (`sv_licenseKey`), your database password or other private values from `server.cfg` into an AI or a public chat.
{% endhint %}

## Use the recommended server artifact

The server artifact is the FXServer build your server runs on. New builds come out often and some of them have bugs, while very old builds cannot run newer scripts. Always use the build FiveM marks as **Recommended**:

{% embed url="<https://docs.fivem.net/docs/server-download/>" %}

Type `version` in the server console to see the build you run now.

To update:

1. Stop the server.
2. Back up your current artifacts folder (the folder with `FXServer.exe`).
3. Download the **Recommended** build and extract it in place of the old artifacts folder.
4. Do not touch your `txData` folder; your server files and txAdmin settings stay there.
5. Start the server and run `version` to check the new build.

## Before you open a support ticket

1. Find the first error of the script in the console, near its `Started resource` line.
2. Restart the script and read its startup errors again.
3. Check that tgiann-core, ox\_lib and your server artifact are up to date.
4. Undo your latest edits and test again.
5. Still broken? Send the full error text or a screenshot of it in your ticket.
