My code doesn't work : Lua errror

Hello My code for bute to display the rank of the person


surface.CreateFont("Douille", {
        font = "Arial",
        size = 27.5,
        weight = 600,
        antialias = true,
})
 
hook.Add( "HUDPaint", "Years")

      
   
	  if ( Player( 2 ):IsUserGroup( "superadmin" ) ) then
        local e = LocalPlayer():GetEyeTrace().Entity
        if !( e and e:IsValid() and e:IsPlayer() ) then return end
        
        local pos = e:GetPos()
       
        pos.z = pos.z + 61 
        pos = pos:ToScreen()
       
        draw.SimpleText( "Fondator", "Douille", pos.x, pos.y, Color( 255, 253, 0, 255 ) )
end
 

Lua error :
[ERROR] lua/autorun/client/hud_grp.lua:22: attempt to call method ‘IsUserGroup’ (a nil value)

  1. unknown - lua/autorun/client/hud_grp.lua:22

[Douille’|6|STEAM_0:1:95882178] Lua Error:

[ERROR] lua/autorun/client/hud_grp.lua:22: attempt to call method ‘IsUserGroup’ (a nil value)

  1. unknown - lua/autorun/client/hud_grp.lua:22

Thank’s you for helping x)

what defines “Player(2)”?

Whole code is just bad.

Here:


surface.CreateFont("Douille", {
        font = "Arial",
        size = 27.5,
        weight = 600,
        antialias = true,
})
 
hook.Add( "HUDPaint", "Years", function()
	if ( LocalPlayer():IsUserGroup( "superadmin" ) ) then
        local e = LocalPlayer():GetEyeTrace().Entity
        if !( IsValid( e ) and e:IsPlayer() ) then return end
        
        local pos = e:GetPos()
       
        pos.z = pos.z + 61 
        pos = pos:ToScreen()
       
        draw.SimpleText( "Fondator", "Douille", pos.x, pos.y, Color( 255, 253, 0, 255 ) )
end )
 

Yes it’s work but : Fondator that mark even if the person is user .

Thank’s you :slight_smile:

[editline]7th August 2015[/editline]

no body ?

No people ? I need help pleas… Thanks :wink:

I’m guessing you want it to display ‘Fondator’ on anyone in the superadmin usergroup?




surface.CreateFont("Douille", {
        font = "Arial",
        size = 27.5,
        weight = 600,
        antialias = true,
})

hook.Add("HUDPaint", "fondatormeansfounder", function()
    local e = LocalPlayer():GetEyeTrace.Entity
    if !(IsValid(e) and e:IsPlayer() and e:IsUserGroup("superadmin")) then return end

    local pos = e:GetPos()
    pos.z = pos.z + 61
    pos = pos:ToScreen()

    draw.SimpleText("Fondator", "Doulle",pos.x,pos.y,Color(255,253,0,255))
end)


If not (And you want to display ‘Fondator’ on every player if you’re superadmin… (why)), Robotboy forgot an end:



surface.CreateFont("Douille", {
        font = "Arial",
        size = 27.5,
        weight = 600,
        antialias = true,
})
 
hook.Add( "HUDPaint", "Years", function()
	if ( LocalPlayer():IsUserGroup( "superadmin" ) ) then
            local e = LocalPlayer():GetEyeTrace().Entity
            if !( IsValid( e ) and e:IsPlayer() ) then return end
        
            local pos = e:GetPos()
       
            pos.z = pos.z + 61 
            pos = pos:ToScreen()
       
            draw.SimpleText( "Fondator", "Douille", pos.x, pos.y, Color( 255, 253, 0, 255 ) )
        end
end )


I want people to see the founder above the head of a superadmin . and not of a user

Yeah, which is what the first code I posted does

edit:
you’re fucking welcome