Whats wrong with this

[ERROR] gamemodes/gmodz/gamemode/cl_thirdperson.lua:80: attempt to index local ‘ang’ (a nil value)

  1. fn - gamemodes/gmodz/gamemode/cl_thirdperson.lua:80

pos = pos - ( ang:Right() * -6 )

There is not enough information to fully comprehend what went wrong, but it says that somewhere in the code ‘ang’ was set to nil value / not initialized at all. My guess is that it resulted from an invalid player entity.
Maybe from a ply:GetAngles() ?

Ok im fairly new to this but ill copy the hole function to the thing real quick

function TPHud()

local ply = LocalPlayer()
local pos, ang = ply:GetBonePosition(2)

pos = pos - ( ang:Right() * -6 ) – line 80

ang:RotateAroundAxis( ang:Forward(), 90 )
ang:RotateAroundAxis( ang:Up(), -90 )

cam.Start3D2D( pos, ang, 0.1 )

local offsetY = -100
local offsetX = -10
local width = 100

– HP Bar
– Draw health if player has any.
if ply:Health() then

local percent = ply:Health() / 100

surface.SetDrawColor( infoBarColors.bg )
surface.DrawRect( offsetX -width / 2, offsetY, width, 15 )

if percent > 0.7 then
surface.SetDrawColor( infoBarColors.healthGood )
elseif percent > 0.3 then
surface.SetDrawColor( infoBarColors.healthOk )
else
surface.SetDrawColor( infoBarColors.health )
end

surface.DrawRect( offsetX - width / 2, offsetY, width * percent, 15 )
draw.SimpleText( ply:Health(), “ChatFont”, offsetX , offsetY + 7, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
draw.SimpleText( “Health”, “Default”, offsetX - 44, offsetY - 8, Color( 150, 150, 150, 255 * ( ply.fadePercent or 1 ) ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )

end

Looks like ply:GetBonePosition(2) did not find the bone and returned nothing.
Unfortunately, it depends on whether the model the player is using has the correct bones.
It may also be that the model was not properly downloaded and loaded on the client, and was not able to look up the bone.

In either case, it’s a bad idea to use a hard coded index. Try replacing ply:GetBonePosition(2) with ply:GetBonePosition(LookupBone(“ValveBiped.Bip01_Head1”)) or you can try tinkering with other bones at http://wiki.garrysmod.com/page/Entity/LookupBone