Knowledge from the fieldRedM

Citizen.InvokeNative drops Y/Z for Vector3-returning natives — must use the Lua wrapper

learning:19

Citizen.InvokeNative drops Y/Z for Vector3-returning natives — must use the Lua wrapper

Context

Calling a Vector3-returning native (e.g. GET_PED_BONE_COORDS, GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS, GET_ENTITY_VELOCITY) via Citizen.InvokeNative(0xHASH, ...).

The trap

The native is documented as returning Vector3. You write:

local pos = Citizen.InvokeNative(0x17C07FC640E86B4E, ped, 7966, 0.0, 0.0, 0.0)
-- later:
print(pos.x, pos.y, pos.z)  -- "attempt to index a number value"

pos is a number, not a vec3. Citizen.InvokeNative only returns the first scalar of multi-return natives — Y and Z are silently dropped. It crashes the moment you index .x/.y/.z.

The fix

Use the Lua wrapper (auto-generated from the native, exposed by name):

local pos = GetPedBoneCoords(ped, 7966, 0.0, 0.0, 0.0)

The wrapper handles the multi-return correctly and gives you a real vec3.

Verified

Hit this in a script that fired magic projectiles from PH_R_Hand (bone_id 7966). Switching from Citizen.InvokeNative(0x17C07FC640E86B4E, ...) to GetPedBoneCoords(...) fixed it immediately. Same pattern applies to GetOffsetFromEntityInWorldCoords, GetEntityVelocity, GetEntityCoords, and any other vec3-returning native.

Rule of thumb: for Vector3/Vector4 return types, prefer the Lua wrapper over raw InvokeNative.

Linked natives

  • GET_PED_BONE_COORDS (0x17C07FC640E86B4E)

Tags: vec3, invokenative, lua-wrapper, bone, gotcha
Category: natives
Source: ch-superman
Created: 2026-05-03T10:23:11.045Z

Back to documentation