I am trying to make a hud for my server but I get attempt to call method 'Armor' <a nil value>
Here is the code that it is a part of:
[lua] local lp = LocalPlayer()
if(IsValid(lp)) then return end
local armor = lp:Armor()
local health = lp:Health()
if(IsValid(lp) and IsValid(lp:GetActiveWeapon())) then
local ammo = 0 local clip = 0 if IsValid( weapon ) then
clip = weapon:Clip1()
ammo = lp:GetAmmoCount(weapon:GetPrimaryAmmoType())
end
end
[/lua]
I have been trying to fix it but to no resolution. Can any of you help?
Where in your addon is this code located?
It is a DarkRP module.
You have:
if(IsValid(lp)) then return end
There's a 'not' missing.
ehm, you are returning when the localplayer is valid ?
shouldn't it be the opposit ?
local lp = LocalPlayer()
if not (IsValid(lp)) then return end
local armor = lp:Armor()
local health = lp:Health()
Thanks, that part works now.
Sorry, you need to Log In to post a reply to this thread.