I Try To make a health bar for my boss zombie but it dont work help please.
local nemesiHealth = getElementHealth(localnemesi)
if nemesiHealth > 100 then
nemesiHealth = nemesiHealth / 2
end
dxDrawRectangle(1107, 54, 211, 13, tocolor(0, 0, 0, 255), true)
dxDrawRectangle(1108, 55, 209*(nemesiHealth/100), 11, tocolor(255, 0, 0, 255), true)
--[[local sw, sh = guiGetScreenSize()
local sx, sy = sw/1920, sh/1080 -- change those number with your resolution
function healthbar()
local plr = localPlayer
local x, y, z = getElementPosition(Nemesis)
target = getPedTarget(plr)
if (not target) then
return false
end
if (not getElementType(target) == "ped" ) then
return false
end
if (not isElementOnScreen(Nemesis)) then
return false
end
local X, Y = getScreenFromWorldPosition(x, y, z)
if (X) then
local healthA = dxDrawRectangle(X - 50, Y - 50, sx*270, sy*27, tocolor(241, 236, 253, 114), false)
local health = getElementHealth(Nemesis)
local lineLength = 256 * (health / 100)
local healthB = dxDrawRectangle(X - 44, Y - 44, lineLength, sy*17, tocolor(9, 172, 213, 254), false)
end
end
addEventHandler("onClientRender", root, healthbar)