• Implementing ARMOR into DarkRP HUD
    3 replies, posted
Hello all, I'm trying to put armor into my HUD but for some reason I'm always getting this error: [ERROR] addons/darkrpmodification-master/lua/darkrp_modules/hud/cl_hud.lua:145: attempt to perform arithmetic on upvalue 'RelativeX' (a nil value) This is my code currently. I tried to follow the same as I did with the Health by putting this before anything else, local DrawArmor = LocalPlayer():Armor() or 0. I think that may be the problem? /*--------------------------------------------------------------------------- Health ---------------------------------------------------------------------------*/ draw.RoundedBox(0, 50, ScrH() - 40, 350, 20, Color(0,0,0,255)) local DrawHealth = LocalPlayer():Health() or 0 local EchoHealth = LocalPlayer():Health() or 0 if DrawHealth > 0 then draw.RoundedBox(0, 50, ScrH() - 40, 350 * DrawHealth / 100, 20, Color(94,196,60,255)) end if DrawHealth > 0 then draw.DrawText( ""..EchoHealth, "Trebuchet24", 60, ScrH() - 42, Color(255,255,255,255))  else draw.DrawText( "", "Trebuchet24", 60, ScrH() - 42, Color(255,255,255,255))  end /*--------------------------------------------------------------------------- Armor ---------------------------------------------------------------------------*/ draw.RoundedBox(0, 50, ScrH() - 65, 350, 20, Color(0,0,0,255)) local DrawArmor = LocalPlayer():Armor() or 0 local EchoArmor = LocalPlayer():Armor() or 0 if DrawArmor > 0 then draw.RoundedBox(0, 50, ScrH() - 65, 350 * DrawArmor / 100, 20, Color(94,196,60,255)) end if DrawArmor > 0 then draw.DrawText( ""..EchoArmorS, "Trebuchet24", 60, ScrH() - 42, Color(255,255,255,255))  else draw.DrawText( "", "Trebuchet24", 60, ScrH() - 42, Color(255,255,255,255))  end Thank you for reading this and hopefully after this armor problem, everything should go smoothly! https://files.facepunch.com/forum/upload/256040/1d5a1e7d-5f33-46e9-9cdd-af4bab92f76a/a26943a871de6bd5c4ca854fa683509d.png
Ah, my bad. I've fixed the error now. Nothing shows up anymore but now the armor still doesn't show up, is the code bad? What did I do wrong? Sorry to be a pain.
Use this Player/Armor
Sorry, you need to Log In to post a reply to this thread.