PiTyUs.Hire me

Engineering

Exports: calling functions in another FiveM resource

How FiveM exports work: defining exports in Lua, JS and the manifest, calling exports.resource:fn(), client vs server exports, return values, errors like 'No such export', and exports vs events.

Updated 10 min readBy PiTyUs · FiveM developer

Overview

Resources are isolated from each other: a local function in one cannot be called from another. Exports are the bridge — a resource publishes a function by name, and any other resource on the same side can call it and get a return value back. Frameworks and libraries are built on them: exports.ox_inventory:AddItem, exports['qb-core']:GetCoreObject().

Defining an export

my_bank/server.lualua
local balances = {}

exports('getBalance', function(playerId)
    return balances[playerId] or 0
end)

exports('addMoney', function(playerId, amount)
    balances[playerId] = (balances[playerId] or 0) + amount
    return balances[playerId]
end)

Registering with exports() in code is the modern way. Older resources list exported function names in the manifest with export (client) and server_export (server); both still work.

Calling an export

another_resource/server.lualua
local balance = exports.my_bank:getBalance(source)
exports.my_bank:addMoney(source, 250)

-- Names with dashes need brackets
local QBCore = exports['qb-core']:GetCoreObject()

Client and server exports

An export defined in a client script can only be called from client scripts; one defined in a server script only from server scripts. To reach the other side you still need an event or a callback — see events and callbacks.

“No such export” and other errors

CauseFix
The resource is not started (yet)Start it earlier in server.cfg or list it in dependencies
Name typo or wrong caseExport names are case-sensitive
Wrong sideA server export called from a client script (or the reverse)
Called at load time before the other resource registered itCall inside a function or after a short wait, or use dependencies
Resource was renamedThe folder name is the resource name — update the call

Exports vs events

ExportsEvents
DirectionSame side onlySame side or across the network
Return valueYes, directlyNo (use callbacks)
CouplingCaller must know the resource nameLoosely coupled by event name
Best forAPIs: inventories, frameworks, utilitiesNotifications and cross-network messages

A good resource offers both: exports for other developers to call its API, and events it fires when something happens.

Performance note

Each export call crosses resource boundaries and serialises arguments. Calling one inside a per-frame loop is a common hidden cost. Cache results that do not change often (a framework object, a config) in a local at start-up.

Frequently asked questions

How do I call a function from another resource in FiveM?

The other resource exports it with exports('name', fn); you call it with exports.resourceName:name(...).

What does 'No such export' mean?

The resource is not started, the export name is misspelled, or you are calling it from the wrong side (client vs server).

Can a client call a server export?

No. Exports are same-side. Use an event or a callback to reach the server.

Why do I need brackets in exports['qb-core']?

Lua identifiers cannot contain dashes, so resource names with dashes must use bracket syntax.

Need this built, not just explained?

Ten years of FiveM work, from Lua to NUI

Custom resources, React NUI, ESX / QBCore / Qbox integration, OneSync performance audits and security reviews — plus the websites and SEO around your server brand.

Related guides