Onex
Onex
Home
Products
Documentation
Changelog
Login with FiveM
  • 👋 Welcome
  • Claim Purchase
  • Translations
    • Body Attachments
      Installation
      Integration
    • Weaponmeta
    • Voice Interaction
Artifacts Tracker
  1. Onex Scripts
  2. Scripts_guides / Api
Ctrl K

RUNTIME ATTACHMENT VISIBILITY CONTROL#

Runtime attachment exports let other resources toggle a player's manual attachments or loadout groups — and temporarily hide or show their body attachments — without a script restart or config edit. Changes are per-player and pushed to the client immediately on call.

Exports come in two flavours:

  • Client exports run on the local player's client and act on that player.
  • Server exports run server-side, take a target player's source id, and forward the change to that player's client.

Client exports are called with exports['onex-bodyAttachments']:<name>(...) from client scripts. Server exports use the same syntax from server scripts, with the target player's src as the first argument.

Client exports#

toggleObject#

Toggles a single manual object on or off for the local player.

Syntax
local state = exports['onex-bodyAttachments']:toggleObject(objectId, state)

Parameters#

ArgumentTypeDescription
objectIdstringID of the object (the key in the objects definitions table, e.g. "revolver"). Only objects whose type is "manual" respond — weapon/item objects are driven by ownership, not toggles.
statebooleanOptional. true = on, false = off. Omit or pass nil to flip the current state.

Return value#

true -- object is now active false -- object is now inactive

Example#

Your Script
-- Force a manual holster prop on exports['onex-bodyAttachments']:toggleObject("dutybelt_radio", true) -- Flip it back off later exports['onex-bodyAttachments']:toggleObject("dutybelt_radio")

toggleGroup#

Toggles every manual member of a loadout group together (e.g. a full duty belt).

Syntax
local state = exports['onex-bodyAttachments']:toggleGroup(groupId, state)

Parameters#

ArgumentTypeDescription
groupIdstringID of a group defined in the groups definitions table. A group holds members = { objectId, ... }.
statebooleanOptional. Forces every manual member on/off. Omit or pass nil to flip based on the first member's current state.

Return value#

true -- group turned on false -- group turned off, OR group does not exist / has no members

Example#

Your Script
-- Turn the whole police belt on exports['onex-bodyAttachments']:toggleGroup("police_belt", true) -- Flip the whole belt off exports['onex-bodyAttachments']:toggleGroup("police_belt")

hideAllAttachments#

Temporarily suppresses every attachment on the local player. Session-only — not persisted.

Syntax
exports['onex-bodyAttachments']:hideAllAttachments()

Parameters#

None.

Return value#

None. This is a fire-and-forget visibility override.

Example#

Your Script
-- Hide everything before a cutscene / strip search / minigame exports['onex-bodyAttachments']:hideAllAttachments()

showAllAttachments#

Clears the "hide all" override and any per-object temp hides, restoring the player's attachments.

Syntax
exports['onex-bodyAttachments']:showAllAttachments()

Parameters#

None.

Return value#

None.

Example#

Your Script
-- Restore everything after the cutscene ends exports['onex-bodyAttachments']:showAllAttachments()

setAttachmentHidden#

Temporarily hides or shows a single attachment. Session-only per-object override, independent of the persisted eye-toggle.

Syntax
local hidden = exports['onex-bodyAttachments']:setAttachmentHidden(objectId, hidden)

Parameters#

ArgumentTypeDescription
objectIdstringID of the object to hide/show.
hiddenbooleanOptional. true = hide, false = show. Omit or pass nil to flip the current state.

Return value#

true -- object is now hidden false -- object is now shown, OR objectId was not a string

Example#

Your Script
-- Hide just the revolver exports['onex-bodyAttachments']:setAttachmentHidden("revolver", true) -- Toggle it back exports['onex-bodyAttachments']:setAttachmentHidden("revolver")

Server exports#

Server exports mirror the temp hide/show client exports, but target a player by their server id. They are dispatched to that player's client immediately.

hideAllAttachments#

Suppresses every attachment on a target player.

Syntax
local ok = exports['onex-bodyAttachments']:hideAllAttachments(source)

Parameters#

ArgumentTypeDescription
sourcenumberServer ID of the target player.

Return value#

true -- dispatched to the player's client false -- source was invalid

Example#

Your Script
exports['onex-bodyAttachments']:hideAllAttachments(source)

showAllAttachments#

Restores all attachments on a target player (clears "hide all" and per-object temp hides).

Syntax
local ok = exports['onex-bodyAttachments']:showAllAttachments(source)

Parameters#

ArgumentTypeDescription
sourcenumberServer ID of the target player.

Return value#

true -- dispatched to the player's client false -- source was invalid

Example#

Your Script
exports['onex-bodyAttachments']:showAllAttachments(source)

setAttachmentHidden#

Hides or shows a single attachment on a target player.

Syntax
local ok = exports['onex-bodyAttachments']:setAttachmentHidden(source, objectId, hidden)

Parameters#

ArgumentTypeDescription
sourcenumberServer ID of the target player.
objectIdstringID of the object to hide/show.
hiddenbooleantrue = hide, false = show.

Return value#

true -- dispatched to the player's client false -- source was invalid, or objectId was not a string

Example#

Your Script
exports['onex-bodyAttachments']:setAttachmentHidden(source, "revolver", true)

Toggles are manual-only. toggleObject and toggleGroup only affect objects whose type is "manual". Weapon and item attachments render from ownership and cannot be forced on with these exports.

Temp hide/show is session-only. Hide/show state (both "hide all" and per-object) is stored in memory and is automatically cleared on resource restart or when the player rejoins. Re-apply it on player load if you need it to persist across sessions. Server exports are fire-and-forget — the return value reports that the change was dispatched, not that the client has applied it.

Use cases#

ScenarioHow
Cutscenes & strip searchesCall hideAllAttachments before the scene and showAllAttachments after to cleanly remove all body props.
Prison / jail intakeServer-side, hide a specific player's weapons and gear with setAttachmentHidden(src, ...) while they're processed, then restore on release.
Minigames & arenasNormalise appearance by hiding everyone's attachments for a fair deathmatch or shooting-range session.
Gunsmith & loadout menusToggle manual holster/belt props live with toggleObject / toggleGroup as the player equips or removes gear.
Admin / staff toolingForce-hide or reveal a reported player's attachments remotely with the server exports for moderation or debugging.

Assignments are stored in memory only and are automatically cleared when the player drops. Re-apply them on player join if persistence across sessions is required.

Last updated about 5 hours ago

Quick Links

All DocumentationOur Products