DarkRP Variables?

So hey I were making my first HUD for DarkRP. I were wondering if there were any variables for the players job name, money and salary? I tried the “getDarkRPVar” method but it does not seem to work. Here is the error:



[ERROR] addons/darkrp_mod/lua/darkrp_modules/androids_hud/cl_hud.lua:35: attempt to call method 'getDarkRPVar' (a nil value)
  1. unknown - addons/darkrp_mod/lua/darkrp_modules/androids_hud/cl_hud.lua:35
   2. doInclude - [C]:-1
    3. loadModules - gamemodes/darkrp/gamemode/libraries/modificationloader.lua:102
     4. Call - gamemodes/darkrp/gamemode/libraries/modificationloader.lua:147
      5. unknown - gamemodes/darkrp/gamemode/cl_init.lua:53


Here is the bit of code.



local ply = LocalPlayer()
local playermoney = ply:getDarkRPVar( "money" ) or 0


I have not really found another way of doing this… Do you have one? Please help.

Update 1:

So I am just trying to make a text on the screen that says what job you are, how much money is in your wallet and your salary. Like this



Job: Mayor | Money: 49054 | Salary: 50


But it is one the screen somewhere.



local ply = LocalPlayer()
local playermoney = ply:getDarkRPVar( "money" ) or 0
hook.Add( "HUDPaint", "HUDIdent", function ()
       draw.SimpleText( "Money: " .. playermoney, ScrW() / 2, ScrH() / 2, Color( 255, 255, 255, 255 ) )
end)


Would it be something like that or no?
PS: The “ply” variable is not nil. Its the same thing as writing



local playermoney = LocalPlayer():getDarkRPVar( "money" ) or 0


… I think.

I made this stuff in the darkrp modifictation as a module. Should I make it as a normal addon in the addons folder or nah?

Could you post more code? Context is needed.

“ply” is probably NULL. Try doing it post

GM:InitPostEntity.

I have updated for more info.

Txikes answer is the correct one. You also need not cache the local player value. Just get it by calling LocalPlayer again. Its good to cache sometimes but this isn’t a case that requires it.

Thank you!