Nametags above the Head?

How do I make it so that people can see there own name tags above there head?

Like if I looked up I would see my own name above my head. Does anyone know how I would do that?

Tried to use the below code but it doesn’t seem to be working.



local Enabled = CreateClientConVar("nametags", 1, true, false)


local offset = Vector(0,0,85)




function ShowNameTags(ply)
--    if not (Enabled:GetBool() and ValidEntity(self) and self:Alive() and self != LocalPlayer()) then return end
    
//    local ang = 90--LocalPlayer():EyeAngles()
//    local pos = ply:GetPos() + offset + ang:Up()


    local pos = self:GetPos()
    local ang = self:GetAngles()
    
    ang:RotateAroundAxis(ang:Forward(), 90)
    ang:RotateAroundAxis(ang:Right(), 90)
    
    cam.Start3D2D(pos, Angle(0, ang.y, 90), 0.25)
        draw.DrawText(self:Nick(), "DermaLarge", 2, 2, team.GetColor(self:Team()), TEXT_ALIGN_CENTER)
    cam.End3D2D()
end
hook.Add("PostPlayerDraw", "ShowNameTags", ShowNameTags)


you shouldn’t be using “self”



function ShowNameTags(ply)
    
    local offset = Vector(0,0,75)
    
     -- Position of the text. (above ply's head)
    local pos = ply:GetPos() + offset
    
     -- The angle YOU'RE looking.
    local ang = LocalPlayer():EyeAngles()
    
     -- Transform angles so text is parallel with your screen.
    ang:RotateAroundAxis(ang:Forward(), 90)
    ang:RotateAroundAxis(ang:Right(), 90)
    
     -- Draw the text in 3d space.
    cam.Start3D2D(pos, Angle(0, ang.y, 90), 0.25)
        draw.DrawText(ply:Nick(), "DermaLarge", 2, 2, team.GetColor(ply:Team()), TEXT_ALIGN_CENTER)
    cam.End3D2D()
    
end
hook.Add("PostPlayerDraw", "ShowNameTags", ShowNameTags)


Unable to see my own player name above my head when looking up but I’m able to see other players names fine.

that’s because of the PostPlayerDraw hook, which isn’t called for you because your player model isn’t being drawn. however, in third-person it will draw.

perhaps you’d want to change the hook to PostDrawOpaqueRenderables, then iterate through all players that way.