# Write your first FiveM script in Lua

Source: https://rpbase.org/guides/your-first-fivem-script
Publisher: RP Base (https://rpbase.org)
Updated: 2026-11-12

> Make a folder with an fxmanifest.lua and a client.lua, register a command with RegisterCommand, start it with ensure and use restart yourscript after each change. Server code goes in server.lua and talks to the client through events.

A small working FiveM resource from scratch: the manifest, a client command, a server event and how to test changes without restarting the whole server.

## The folder
```
hello/
  fxmanifest.lua
  client.lua
  server.lua
```

## The manifest
```lua
fx_version 'cerulean'
game 'gta5'
lua54 'yes'

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

## A client command
```lua
RegisterCommand('hello', function()
    local name = GetPlayerName(PlayerId())
    TriggerEvent('chat:addMessage', { args = { 'RP Base', 'Hi ' .. name } })
    TriggerServerEvent('hello:said')
end, false)
```

## The server side
```lua
RegisterNetEvent('hello:said', function()
    local src = source
    print(('%s said hello'):format(GetPlayerName(src)))
end)
```
`source` is the player who sent the event. Save it in a local first: it changes after any `Wait`.

## Run it
Put the folder in `resources`, add `ensure hello` to server.cfg and restart. After a change type `restart hello` in the server console, no full restart needed.

## Never trust the client
Anything a client sends can be faked. If the client says it earned money, check on the server that it could have.

## Next steps
Read [fxmanifest.lua explained](https://rpbase.org/guides/fxmanifest-explained), then add a UI with [NUI basics](https://rpbase.org/guides/fivem-nui-basics). Stuck? Paste the error in [Scripts and Lua help](https://rpbase.org/forums/development).
