Commands.lua attempt to index a boolean value (local 'xPlayer')

Hello, iam getting this error whenever i try to use /giveweapon command.

and this is the server side code:

ESX.RegisterCommand('giveweapon', 'admin', function(xPlayer, args, showError)
	if args.playerId.hasWeapon(args.weapon) then
		showError(_U('command_giveweapon_hasalready'))
	else
		xPlayer.addWeapon(args.weapon, args.ammo)
	end
end, true, {help = _U('command_giveweapon'), validate = true, arguments = {
	{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'},
	{name = 'weapon', help = _U('command_giveweapon_weapon'), type = 'weapon'},
	{name = 'ammo', help = _U('command_giveweapon_ammo'), type = 'number'}
}})

Thanks in advance :slight_smile:

Pretty sure it happens if xPlayer doesn’t exist. Check you’re spawning correctly and if using Legacy check the readme for conflicting resources.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.