RegisterPedheadshotTransparent not working

Using the below native is returning a nil value for a global function called client-side.

Native
RegisterPedheadshotTransparent(PlayerPedId())

Error
SCRIPT ERROR: @resource/file.lua:<line>: attempt to call a nil value (global 'RegisterPedheadshotTransparent')

However, the below bit of code works somewhat.
Citizen.InvokeNative(0x953563CE563143AF, PlayerPedId())

Code to replicate

local setup = false
local headshot

RegisterCommand('test', function(source, args, rawCommand)
	loadImageProfil()
end)

Citizen.CreateThread(function()
  while true do
	if setup then
		DrawSprite(headshot, headshot, 0.5, 0.5, 0.0375, 0.0653, 0.0, 255, 255, 255, 1000)
	end
    Citizen.Wait(1)
  end
end)

function loadImageProfil()
  	if not setup then
	  CurrentPedModel = GetEntityModel(PlayerPedId())
	 -- local handle = Citizen.InvokeNative(0x953563CE563143AF, PlayerPedId())
	  local handle = RegisterPedheadshotTransparent(PlayerPedId())
	  print(handle)

	  while not IsPedheadshotReady(handle) or not IsPedheadshotValid(handle) do
	    Wait(100)
	  end
	  Citizen.Wait(100)
	  headshot = GetPedheadshotTxdString(handle)
	  	setup = not setup
	elseif setup and headshot ~= nil then
		UnregisterPedheadshot(handle)
		setup = not setup
		print("removed")
	end
end

Did you typo in example code or did you typo the error?
They don’t match.

Also, if you somehow just typo’d example code, try using the newest manifest version https://docs.fivem.net/scripting-reference/resource-manifest/resource-manifest/

1 Like

Apologies, that wasn’t written but I must have missed it.

I have updated my OP/Thread Topic to reflect the correct sample code and error.

It is not a nil value now. However, the FiveM function still isn’t working. The GTA V one is though.

Also, this is using the latest manifest. (NOPE I WASNT!)

Code works fine as pasted in your post, assuming you’re using the right manifest version (not specifying any version is wrong!).

2 Likes

Apologies, I apparently was running an outdated manifest. :man_facepalming:

Please feel free to close this.