PiTyUs.Hire me

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.

Updated 9 min readBy PiTyUs · FiveM developer

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

Clone the addon into a folder for Lua addonsbash
mkdir -p ~/lua-addons && cd ~/lua-addons
git clone https://github.com/overextended/fivem-lls-addon.git
.luarc.json in your projectjson
{
  "$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

In a JS/TS resourcebash
npm install --save-dev @citizenfx/client @citizenfx/server typescript

The packages give typed natives and events. Build setup is in TypeScript scripts.

Other useful extensions

  • An XML extension for .meta files.
  • 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