Create a mod and script with FiveM

March 25, 2026
  • Robin Moretti

In this tutorial, we will see how to create a Lua script and run it in GTA V via FiveM.

Prerequisites:

Preparing the mod in the FiveM server

When installing the local txAdmin server, a resources folder is created. We will add our script there. Example path: C:\Users\$User\Desktop\txData\FiveMBasicServerCFXDefault_BC1780.base\resources

  1. In resources, create a new folder and name it script_mod (or any name you prefer).
  2. Add an fxmanifest.lua file in script_mod and add the following code to it.
fx_version 'cerulean'
game 'gta5'

author 'An awesome dude'
description 'An awesome, but short, description'
version '1.0.0'

resource_type 'gametype' { name = 'My awesome game type!' }

client_script 'monscript.lua'
  1. Create a new file monscript.lua in the same folder and paste the following code:
local spawnPos = vector3(-22.28888, 18.04243, 72)

AddEventHandler('onClientGameTypeStart', function()
    exports.spawnmanager:setAutoSpawnCallback(function()
        exports.spawnmanager:spawnPlayer({
            x = spawnPos.x,
            y = spawnPos.y,
            z = spawnPos.z,
            model = 'a_f_y_yoga_01'
        }, function()
            print("Player spawned at custom location with custom model.")
        end)
    end)

    exports.spawnmanager:setAutoSpawn(true)
    exports.spawnmanager:forceRespawn()
end)
  1. Open the server.cfg file (located at the root of the server) with a text editor and add the following line:
start script_mod

Tip: place this line at the end of the file, after the other resources already listed, to avoid any loading order conflict.

  1. Launch the txAdmin server.
  2. Launch the FiveM client, connect to your local server.

If everything is correctly configured, your character will appear at the position (-22.28888, 18.04243, 72.0) with the model a_f_y_yoga_01.

Reload the script without restarting the game

It is not necessary to close GTA V for every modification:

  • Modify your monscript.lua file in a code editor.
  • Save the changes.
  • Go back to GTA V, open the console with F8 and type: restart script_mod

The restart command reloads the entire resource, which runs the Lua code again. You can also recall the last command with the keyboard's ↑ arrow, like in a terminal.


Translated by AI from the French version.

1
2