Jump to content

Attempt to perform arithmetic on a nil value (Table)


Bilal135

Recommended Posts

local weaponTable = {
-- [weap_id] = { torso, ass, left_arm, right_arm, left_leg, right_leg, head }
 [24] = { 45, 35, 30, 30, 25, 25, 70 },
}


addEventHandler("onPlayerDamage", getRootElement(),
	function (attacker, weapon, bodypart, loss)
		if getElementType(attacker) == "player" and getPlayerWeapon(attacker) and weaponTable[ getPlayerWeapon(attacker) ] then
			setElementHealth(source, getElementHealth(source) - weaponTable[ getPlayerWeapon(attacker) ] [ bodyPart - 2] + loss)
		end
	end
)

This is supposed to set the damage for each weapon according to the body parts, but for some reason, the code isnt working and the only error im getting is this: Attempt to perform arithmetic on 'bodyPart' (a nil value). 

Any help would be appreciated.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...