How to make your first FiveM script in Lua

Make your first FiveM script in Lua: an fxmanifest.lua, a /hello command with a notification and an event to the server and back.

EliteStarHosting Team4 December 20264 min read
FiveM server hosting from €5 a month: view the plans

A FiveM script is called a resource: a folder with an fxmanifest.lua and script files. Here you build the resource hello. When a player types /hello, they get a notification, the script asks the server for an answer and that answer appears in the chat. The code follows the FiveM documentation (December 2026).

Need a server? Our FiveM server hosting starts at €5 a month, with txAdmin ready to go. You can also try one free for 24 hours.

Before you start

  • A FiveM server you can join, with the standard chat resource (every txAdmin recipe has it).
  • A text editor such as Visual Studio Code. Not Word: it adds invisible formatting to your file.
  • Access to txAdmin, for the Live Console.

The three files

On your computer, create a folder hello with three files.

fxmanifest.lua tells FiveM what is in the resource:

fx_version 'cerulean'
game 'gta5'

client_script 'client.lua'
server_script 'server.lua'

cerulean is the current fx_version, and gta5 means FiveM. A client_script runs on every player's PC, a server_script on your server. Since June 2025, all Lua scripts run on Lua 5.4, so you no longer need the old line lua54 'yes'.

client.lua:

RegisterCommand('hello', function()
    -- a notification at the bottom left of the screen
    BeginTextCommandThefeedPost('STRING')
    AddTextComponentSubstringPlayerName('Hello! Your first script works.')
    EndTextCommandThefeedPostTicker(false, false)

    TriggerServerEvent('hello:ask')
end, false)

RegisterNetEvent('hello:answer', function(text)
    TriggerEvent('chat:addMessage', { args = { 'Server', text } })
end)

server.lua:

RegisterNetEvent('hello:ask', function()
    local player = source
    local name = GetPlayerName(player)

    print(name .. ' used /hello')
    TriggerClientEvent('hello:answer', player, 'Hi ' .. name .. ', the server heard you.')
end)

How it works:

  • RegisterCommand creates the command. Players type it in the chat (key T) as /hello.
  • TriggerServerEvent sends an event to the server. RegisterNetEvent catches an event from the other side and runs the function.
  • On the server, source is the ID of the player who sent the event. Store it in a variable straight away: after a Wait, it is no longer correct.
  • TriggerClientEvent sends an event to one player. With -1 instead of player, it goes to everyone.
  • chat:addMessage needs the standard chat resource, which txAdmin's recipes start with ensure chat.

Never trust what a client sends: cheaters can fire server events themselves, with their own values. So check on the server whether a player may do something. See Secure Your Events.

Uploading and starting

  1. In the game panel, open Files and go to the resources folder.
  2. Click Upload, choose Upload Folders and select your hello folder. The manifest must be at resources/hello/fxmanifest.lua, not in an extra subfolder.
  3. Go to server.cfg editor, type hello under Resources, click Add and then Save. It now starts whenever your server starts. This screen also shows your license key, so don't screenshot it.
  4. Start it without a restart: click Tx Admin at the top of your server page, open Live Console and type refresh (FiveM then sees new folders), then ensure hello.

The Upload menu with Upload Files, Upload Folders and Upload from URL

The Resources section of the server.cfg editor with the ensure lines and the Add button

Join your server and type /hello. More about resources: Install scripts (resources).

Changing it without a restart

In Files, click a file, change it and click Save Content. Then type ensure hello in the Live Console: only this resource restarts, your server keeps running. ensure starts a resource, or restarts it if it is already running; restart only works on a running resource. Changed fxmanifest.lua? Type refresh first. Or click Restart under Resources in txAdmin.

Reading errors

Server errors appear in the game panel's Console and in the Live Console, errors in client.lua in your own F8 console in the game.

  • Couldn't find resource hello.: the folder name doesn't match, or you forgot refresh.
  • hello does not have a resource manifest (fxmanifest.lua): the manifest is missing or one folder too deep.
  • Error parsing script @hello/server.lua: a typo, such as a missing bracket or end. The message includes the line number, for example server.lua:6.
  • SCRIPT ERROR: @hello/server.lua:5: an error while running, on line 5, followed by the cause.

More messages and fixes: Fix common FiveM server errors.

Your own server for this? FiveM server hosting from €5 a month.

Online within minutes, DDoS protection included, no contract.