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 vs server
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.
Events are the glue
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 patterns you will use every day
- CreateThread + while true do ... Wait(0) end for client loops. Almost always wrong with Wait(0); usually 100–500 is plenty.
- exports['resource']:functionName() to call into another resource cleanly.
- AddEventHandler for non-net events that stay within one side.
- ox_lib's ox_lib:notify and ox_lib:registerCommand if you are on a modern stack — they handle UX nicely.
Don't be afraid of the docs
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.
Wrapping up
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
Server-owner-friendly tutorials, every week. Browse the marketplace for premium FiveM resources or reach out if you need a custom build.
