Set up VS Code for FiveM
Writing Lua in Notepad is how beginners burn hours on typos. The right editor catches the mistake as you type instead of in the server console after a restart. This lesson sets up VS Code the way working FiveM developers run it in 2026: the Lua language server plus the Cfx native definitions, so RegisterCommand autocompletes and a missing end lights up red.
Build it
Install VS Code
Download and run the Windows User Installer, accept the defaults, and tick the Open with Code context-menu options on the Additional Tasks screen.
Install the Lua language server
Open the Extensions panel (the four-squares icon in the left bar, or Ctrl+Shift+X). Search for Lua and install the one published by sumneko (the identifier is sumneko.lua, marketplace name "Lua"). This is the language server: autocomplete, go-to-definition, and live error checking.
Do not confuse it with older "Lua" extensions that only do syntax coloring. You want the one with millions of installs by sumneko.
Add the Cfx native definitions
Still in Extensions, search for Cfx Lua and install cfxlua-vscode published by overextended (identifier overextended.cfxlua-vscode). It plugs FiveM's native function definitions into the Lua language server.
Configs for this extension change over time, so treat its marketplace README as the source of truth for the exact .luarc.json snippet. The reliable parts below do not change.
Open your server as a workspace and add .luarc.json
In VS Code choose File -> Open Folder and pick your server-data (or resources) folder. Opening the folder, not a single file, is what lets the language server see your whole project.
At the root of that folder, create a file named .luarc.json and paste this safe baseline. It sets the Lua version FiveM uses and stops false "undefined global" warnings for the most common FiveM globals:
{
"runtime.version": "Lua 5.4",
"diagnostics.globals": [
"exports",
"RegisterCommand",
"RegisterNetEvent",
"AddEventHandler",
"TriggerEvent",
"TriggerServerEvent",
"TriggerClientEvent",
"Citizen",
"vector3",
"vector4",
"GetResourceState",
"GetPlayerName"
]
}
With the Cfx Lua extension installed, the full native list autocompletes on top of this. The .luarc.json is just the floor.
Prove autocomplete works
Open any client.lua or server.lua (or make a scratch test.lua). Start typing:
RegisterComm
A suggestion popup should offer RegisterCommand. Press Tab to accept it. Then delete an end from a function and watch the red squiggle appear under the line.
Keep reading the full lesson
Sign in to start, then unlock every step of this lesson and the full FiveM School with a membership.
- If something went wrong
- What you can do now
- Try it yourself
The remainder of Set up VS Code for FiveM is available to FiveM School members.