Getting started
Setting up VS Code for FiveM scripting
Set up Visual Studio Code for FiveM: the Lua Language Server extension, native and CfxLua types with fivem-lls-addon (the successor of cfxlua-vscode), .luarc.json with ox_lib as a library, TypeScript typings, useful extensions, and workspace habits that prevent bugs.
Overview
Writing FiveM Lua in a plain text editor means guessing native names, argument orders and typos until the F8 console complains. With the right VS Code setup you get autocompletion for every native, warnings for undefined variables and hover documentation — before you ever start the server.
01Step 1: the Lua extension
In VS Code’s Extensions panel install “Lua” by sumneko (the Lua Language Server, LuaLS). It provides diagnostics, completion, go-to-definition and annotation support. FiveM uses CfxLua, a modified Lua 5.4, so the language server needs FiveM definitions next.
02Step 2: FiveM types with fivem-lls-addon
mkdir -p ~/lua-addons && cd ~/lua-addons
git clone https://github.com/overextended/fivem-lls-addon.git{
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"workspace.checkThirdParty": "Ask",
"workspace.userThirdParty": ["/home/dev/lua-addons"],
"workspace.library": ["/home/dev/fxserver/server-data/resources/ox_lib"]
}Adjust the paths (on Windows, for example C:/lua-addons). The addon brings FiveM, RedM and CFX natives plus runtime globals such as CreateThread, promise, json, vectors and state bags. Commit a .luarc.default.json and keep personal paths in an ignored .luarc.json.
JavaScript and TypeScript
npm install --save-dev @citizenfx/client @citizenfx/server typescriptThe packages give typed natives and events. Build setup is in TypeScript scripts.
Other useful extensions
- An XML extension for
.metafiles. - ESLint and Prettier for NUI projects.
- GitLens or the built-in Git panel — see Git for FiveM.
- EditorConfig to keep indentation consistent across a team.
Habits the setup enables
- Fix every yellow “undefined global” warning — most are typos that would crash at runtime.
- Write annotations for your own functions — see Lua annotations.
- Open the whole resources folder as a workspace so exports and requires resolve.
Frequently asked questions
What is the best editor for FiveM Lua?
VS Code with the Lua Language Server extension and FiveM types from fivem-lls-addon is the common setup.
How do I get FiveM native autocomplete in VS Code?
Install the Lua extension, clone fivem-lls-addon and add its parent folder to workspace.userThirdParty in .luarc.json.
Is the CfxLua IntelliSense extension still maintained?
No, it is discontinued and refers users to fivem-lls-addon.
How do I get ox_lib autocomplete?
Add the ox_lib resource folder to workspace.library in .luarc.json.
Need this built, not just explained?
Ten years of FiveM work, from Lua to NUI
Custom resources, React NUI, ESX / QBCore / Qbox integration, OneSync performance audits and security reviews — plus the websites and SEO around your server brand.
Related guides
- EngineeringTyping your FiveM Lua with annotationsAnnotate functions with ---@param name type and ---@return type, describe table shapes with ---@class and ---@field, restrict strings with ---@alias, and mark variables with ---@type. The language server then checks calls and completes fields. Annotations are comments, so they cost nothing at runtime. Start with configs and shared data shapes — they catch the most bugs.
- Getting startedWrite your first FiveM script, step by stepCreate a folder resources/my_first, add an fxmanifest.lua with fx_version 'cerulean', game 'gta5', a client_script and a server_script, then write a client command that loads a model with RequestModel, waits for HasModelLoaded, spawns it with CreateVehicle and seats the player with SetPedIntoVehicle. Add ensure my_first to server.cfg, restart, and type /car adder in game.
- Getting startedRunning a local FiveM server for developmentRun FXServer on your PC (txAdmin or vanilla), point it at a copy of your server-data and a separate development database, and connect from FiveM with connect localhost:30120. sv_lan true makes the server LAN-only and skips the licence key check. Use ensure <resource> after edits and refresh for new resources, keep game build and OneSync settings identical to production, and test multiplayer logic with a second account or machine.
- EngineeringWriting FiveM resources in TypeScriptInstall @citizenfx/client, @citizenfx/server, TypeScript and esbuild. Write src/client and src/server, bundle each into a single file (dist/client.js, dist/server.js), and list those in the fxmanifest. Client JS has the ES2017 standard library but no browser or Node APIs; server JS runs on Node.js 16 by default, or Node 22 with node_version '22' in the manifest. Type other resources’ exports by extending CitizenExports.