How to add FiveM scripts and resources without errors
Technical guide to adding FiveM resources without breaking dependencies: folder structure, server.cfg load order, fxmanifest, conflicts and diagnostic logs.
Adding resources in FiveM looks trivial until the server won’t boot, the console shows Couldn't load resource or a new script takes down the entire framework. Most errors don’t come from the resource itself — they come from the wrong folder structure, an invalid fxmanifest, incorrect order in server.cfg or conflict with another script.
This guide is for anyone running their own FiveM server (Windows or Linux), who already has a framework installed (ESX or QBCore) and wants to add community or paid scripts without breaking anything. Estimated time: 10 to 15 minutes per properly tested resource.
Prerequisites
A FiveM server (FXServer) running — Windows Server 2019+ or Ubuntu 22.04/24.04. Framework installed (ESX Legacy, QBCore or other). Access to the server filesystem (RDP on Windows or SSH on Linux). Access to the server console to reload resources without restarting.
/path/to/server-data resources/ server.cfg 30120 If your server is on a Linux VPS, connect via SSH first. On Windows, connect via RDP and open a PowerShell terminal in the server folder.
Understanding the structure of a resource
Before adding anything, it’s worth knowing what FXServer expects. A valid FiveM resource is a folder inside resources/ (or in subfolders prefixed with [category]) containing at least an fxmanifest.lua at the root. Without that file, FXServer ignores the resource — no matter how many .lua or .js files are inside.
The typical structure:
resources/
└── [scripts]/
└── my-resource/
├── fxmanifest.lua
├── client.lua
├── server.lua
├── config.lua
└── html/
├── index.html
├── style.css
└── script.js
Folders in brackets ([scripts], [esx], [qb]) are just visual organization — FXServer scans them recursively. You can nest 2-3 levels deep without problems. Avoid more than that to keep maintenance simple.
The minimal fxmanifest.lua
Every resource needs to declare the API version and target game. The minimum viable file:
fx_version 'cerulean'
game 'gta5'
author 'Author name'
description 'Short description'
version '1.0.0'
client_scripts {
'client.lua'
}
server_scripts {
'server.lua'
}
shared_scripts {
'config.lua'
}
fx_version 'cerulean' is the current recommended value (supports modern FiveM features). Older versions like adamant or bodacious still work but lose capabilities.
Adding a resource step by step
Copy the resource folder into resources/ on the server. On Linux, via scp or SFTP:
scp -r my-resource/ user@server-ip:/path/to/server-data/resources/[scripts]/On Windows, drag through the RDP session or use an SFTP client like WinSCP. Place the folder inside a bracketed category — [scripts], [custom], [esx], [qb] — to keep things organized. Don’t copy the .zip: extract it first.
Confirm fxmanifest.lua exists at the resource root. If the file is named __resource.lua (legacy format), the resource still works, but consider migrating to fxmanifest.lua — some modern resources no longer run with the legacy format.
ls /path/to/server-data/resources/[scripts]/my-resource/You should see fxmanifest.lua listed. If not, the resource is poorly packaged.
Open server.cfg at the server root and add the activation line:
ensure my-resourcePlace this line in the correct order: after the framework and dependencies, before scripts that depend on it. Practical example with QBCore:
# Frameworks first
ensure qb-core
# Libraries and dependencies
ensure ox_lib
ensure oxmysql
# Gameplay scripts
ensure qb-multicharacter
ensure qb-spawn
ensure my-resourceThe start name command loads the resource once, but doesn’t respect refresh or clean restart. ensure name reloads the resource on hot-reload and guarantees dependency order. Always prefer ensure on production servers.
Save server.cfg and reload the resource in the server console (no need to restart everything):
refresh
ensure my-resourceThe refresh command makes FXServer rescan the resources/ folder and detect new resources. Then ensure my-resource starts it. If the resource was already running, use restart my-resource instead of ensure to reload it.
Check the server console that the resource started without errors. You should see something like:
Started resource my-resourceIf you see Couldn't load resource my-resource or Error parsing script, open the logs and jump to the troubleshooting section below.
Verifying everything is working
In the server console, run resources to see the full list of active resources. Your resource name should appear with status started. If it shows up as stopped, it was recognized but isn’t running — check the ensure in server.cfg.
To test functionally, join the server with your FiveM client. Client-side scripts usually react to commands (/command), inventory items or automatic events. Open the F8 client console (~ or F8) — Lua or JavaScript errors on the client side show up there with a stack trace.
FXServer writes fxserver.log (Linux) or console.log (Windows) in the server folder. Keep a terminal running tail -f logs/fxserver.log while testing — you’ll see errors in real time without opening the panel.
Common troubleshooting
”Couldn’t load resource X”
Almost always a missing or invalid fxmanifest.lua. Check:
- The file is named exactly
fxmanifest.lua(lowercase, with.lua) - It declares
fx_version 'cerulean'andgame 'gta5' - Valid Lua syntax (balanced commas and quotes)
If the file is fine, confirm that the folder name matches exactly the ensure in server.cfg. On Linux, MyResource and myresource are different folders — case-sensitive.
”Error loading script” with a Lua error
The console shows the exact line of the error. Frequent causes:
- Framework variable used before the framework loaded (wrong order in
server.cfg) - Missing dependency (
exports['ox_lib']called withoutox_librunning) - Lua syntax broken by manual editing
To isolate: comment the resource in server.cfg, restart, then add resources one by one until you reproduce the error.
Server crashes on startup
Comment out every ensure except the core ones (mapmanager, chat, spawnmanager, sessionmanager, framework). Restart. If it boots without crashing, add resources one at a time until you identify the culprit. This process is slow but it’s the only reliable way when the error happens very early in the boot.
Resources with obfuscated Lua (code like _G[string.char(...)]) may contain backdoors, player data exfiltration or unauthorized remote commands. Use only scripts from trusted sources — verified Cfx forum, Tebex, GitHub with public history. Legitimate paid scripts use escrow and never force full obfuscation.
Conflict between two scripts on the same event
Two resources registering a handler for the same event (AddEventHandler('playerSpawned', ...)) may compete for execution order. FiveM doesn’t guarantee handler order across resources for the same event. Solution: explicitly declare a dependency in the fxmanifest.lua of the resource that must run later:
dependencies {
'other-resource'
}
This guarantees other-resource loads first.
Next steps
With a clean structure and resources running stably, it’s worth digging into:
- Script optimization: identify resources that consume a lot of CPU using
resmonon the client (Shift+~). Resources above 1.0ms client-side deserve review. - Automated resource backups: versioning the
resources/folder in a private Git repo prevents losses when you break something while testing. - Script whitelist: on roleplay servers, keeping a curated list of approved resources reduces bug and exploit surface.
- Separate databases per category: heavy scripts (jobs, inventory) can use isolated databases to reduce contention.
If you’re running FiveM in production with 32+ slots and want infrastructure that keeps low latency for the Americas, Hostini’s game servers deliver sub-30ms latency across the region with DDoS protection included in the price.
Frequently asked questions
Why does 'Couldn't load resource' show up even with the folder in the right place?
It's almost always an invalid or missing fxmanifest.lua. FiveM requires `fx_version` and `game` declared at the top of the file. Without them, the resource is silently ignored at runtime. Also check that the folder name matches exactly the `ensure` in server.cfg — Linux is case-sensitive.
Can I just copy the resource folder and restart the server?
Not enough. You need to add `ensure resource-name` in server.cfg. Just dropping the folder in resources/ makes FxServer recognize the resource as available, but won't start it. Use `ensure` instead of `start` — `ensure` reloads the resource on hot-reload and respects dependencies.
In what order should resources be loaded in server.cfg?
Frameworks first (ESX, QBCore), then shared libraries (ox_lib, oxmysql, mysql-async), then gameplay resources that depend on them. Reversing this order causes circular dependency errors and scripts that can't see framework exports.
How do I know if a resource is compatible with my framework?
Read the resource's fxmanifest.lua — it declares `dependencies` or `shared_scripts` pointing to qbcore-bridge, es_extended or similar. In general, scripts labeled 'QBCore' won't run on ESX without adaptation. Also check the framework version: scripts for QBCore 1.2.x break on older branches.
The server crashes on startup with a new resource. How do I find which one?
Comment out every `ensure` in server.cfg and add them back one at a time, restarting between each. The resource that causes the crash shows up with a Lua/JS error in the console. Another option is to run with `+set sv_enforceGameBuild` and check console.log under logs/ in the server folder.
Can I edit a script while the server is running?
Yes. Use `restart resource-name` in the server console or via rcon. This reloads only the changed resource without dropping players. Watch out for scripts that open persistent connections (database, WebSocket) — they may keep orphan handlers until a full restart.