Skip to main content
TRACK B·DEVELOPER SETUP·Verified June 2026 · Lua 5.4 · ox_lib 3.x
Learning with an AI assistant?
Copies this lesson plus 2026 ground rules (no lua54 'yes', Cfx.re Portal, correct callback signatures) as a ready-to-paste mentor prompt.

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.

You'll build
A FiveM-ready editor: VS Code with the Lua language server and the Cfx Lua native definitions, so you get autocomplete and red squiggles before you ever restart the server.
Time
~15 minutes.
You need
A Windows PC and a resources folder to open. No coding yet, just tooling.
You'll learn
Install VS Code -> add the Lua extension -> add Cfx native definitions -> open your server as a workspace -> prove autocomplete works
BEFORE YOU START

Build it

Install VS Code

VS Code opens and you can open a folder as a workspace.

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

The Lua extension by sumneko is installed and enabled.

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

FiveM natives autocomplete, not just plain Lua.

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

The editor treats your resources as one Lua 5.4 project with FiveM globals known.

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:

code
{
"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

Typing a native shows a suggestion popup and a missing end shows a red squiggle.

Open any client.lua or server.lua (or make a scratch test.lua). Start typing:

code
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.

Still ahead in this lesson
  • 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.