A friendly first introduction to Lua specifically for FiveM — client vs server, events, and the patterns you will use every day.
If you are about to write your first Lua line, the good news is FiveM only uses a small slice of the language and you can be productive within a week.
Client-side code runs on each player's machine. It draws UI, captures keys, plays animations, spawns props the player sees. Server-side code runs once on the server and is the source of truth for money, items, and persistence. The mental rule: trust nothing the client sends.
Client-server communication happens through events. RegisterNetEvent('myresource:doThing') on the receiving side, TriggerServerEvent('myresource:doThing', payload) on the sending side. Always validate the payload server-side before acting on it.
The Cfx native reference (docs.fivem.net/natives) is your best friend. Every native is searchable, with parameter types and a short description. When something doesn't work, read the native signature carefully — most bugs are wrong argument order.
Write a small useless resource first. A command that prints hello world. A target zone that opens a notification. Once those work, you have all the pieces to build anything bigger.
Written by
Mike Rodriguez
Questions? Browse our products or contact us