Adding variables to gamemode hud?

In my game mode, I made a simple score system (which I have confirmed works) in which players get points when they kill enemies. How do I make the player’s score appear in the hud?

Paste the code you have currently.

init.lua
[lua]
function GM:PlayerInitialSpawn(ply)
ply.points = 500
end

function GM:OnNPCKilled( victim, killer, weapon )
if killer:IsPlayer() then
killer.points = (killer.points + 80)
end
end
[/lua]

cl_init.lua
[lua]
function GM:HUDShouldDraw(name)
if (name == “CHudHealth” or name == “CHudBattery” or name == “CHudWeapon”) then
return false
elseif not(name == “CHudHealth” or name == “CHudBattery” or name == “CHudWeapon”) then
return true
end
end
[/lua]

Where are you actually drawing the hud?

Add:

[lua]
killer:SetNWInt( “kpoints” , killer.points )
[/lua]

in init.lua, after

[lua]
killer.points = (killer.points + 80)
[/lua]

Then whenever you want to get the value just do

[lua]
LocalPlayer():GetNWInt( “kpoints” )
[/lua]

Make sure you check if the player has points or not, if he doesn’t set it to 0. ( PlayerInitialSpawn )

Worked, thanks!