[HELP] Health Bar OVERHEAD for lua

Hey guys i have been trying to add health bar overhead: something like this:

I did follow 2 snippets but still having problem,
i followed this one

AND found this code for lua

local MaxDistance = 35
local Width = 0.03
local Height = 0.0085
local Border = 0.001
local ScreenResolution = GetScreenActiveResolution()

function DrawHealthBar(X,Y,Z,CamCoord,CamFov,OtherPed,PlayerPed)
    Distance = GetDistanceBetweenCoords(CamCoord[0],CamCoord[1],CamCoord[2],X,Y,Z,true)
    if Distance <= MaxDistance then
        local ScreenCoord = GetScreenCoordFromWorldCoord(X,Y,Z)
        if ScreenCoord[0] == 0 then
            return
        end
        local Scale = Distance / MaxDistance
        Scale = (Scale + Scale * CamFov) /2
        if Scale < 0.6 then
            Scale = 0.6
        end
        local Health = GetEntityHealth(OtherPed)
        Health = Health < 100 ? 0 : (Health - 100) / 100

        local Armour = GetPedArmour(OtherPed) / 100
        Y = ScreenCoord[2]
        Y -= Scale * (0.005 * (ScreenResolution[1] / 1080))
        X = ScreenCoord[1]

        if IsPlayerFreeAimingAtEntity(GetPlayerPed(-1), OtherPed) then
            local Y2 = Y2
            if Armour > 0 then
                local X2 = X - Width / 2 - Border / 2
                DrawRect(X2, Y2, Width + Border * 2, 0.0085, 0, 0, 0, 200)
                DrawRect(X2, Y2, Width, Height, 68, 121, 68, 255)
                DrawRect(X2 - (Width / 2) * (1 - Health), Y2, Width * Health, Height, 114, 203, 114, 200)

                X2 = X + Width / 2 + Border / 2
                DrawRect(X2, Y2, Width + Border * 2, Height + Border * 2, 0, 0, 0, 200)
                DrawRect(X2, Y2, Width, Height, 41, 66, 78, 255)
                DrawRect(X2 - (Width / 2) * (1 - Armour), Y2, Width * Armour, Height, 48, 108, 135, 200)
            else
                DrawRect(X, Y2, Width + Border * 2, Height + Border * 2, 0, 0, 0, 200)
                DrawRect(X, Y2, Width, Height, 68, 121, 68, 255)
                DrawRect(X - (Width / 2) * (1 - Health), Y2, Width * Health, Height, 114, 203, 114, 200)
            end
        end
    end
end)

Citizen.CreateThread(function()
while true do
    wait(1)
    
    local CamCoord = GetGameplayCamCoords()
    local Fov = GetGameplayCamFov()

    for Player = 0, 64 do
        if NetworkIsPlayerActive(Player) and GetPlayerPed(Player) ~= GetPlayerPed(-1) then
            local Target = GetPlayerPed(Player)
            if DoesEntityExist(Target) not IsEntityDead(Target) then
                local TargetPosition = GetEntityCoords(Target, true)
                DrawHealthBar(TargetPosition[0],TargetPosition[1],TargetPosition[2] + 0.5, CamCoord, Fov, Target, Player)
            end
        end
    end
end
end)

I have been trying to a just to get it fixed, please help me out guys im in trouble and have been sitting in hours for this, what am i doing wrong? You can check the link for the snipped in other language too
bless you guys

im still having problem, anyone with any tips?

like i said in another post to another the script is okay, but it needs some changes to work on lua

Good luck my friend, check the other post if u need more info :wink:

this problem is very hard to explain on text, are you free for a discord call any day? if so be free to add me on discord ( Ludaro ) :wink: ill help u there.