HUD Issues: HUD won't draw defined value

I’m having problems with trying to make this HUD, it’s using a custom var and I already defined it through a umsg and it’s coming back with “nil”
[lua]
draw.SimpleTextOutlined(“Money:$”…Money, “TargetID”, 50,350, Color(0,255,0,255), TEXT_ALIGN_TOP, TEXT_ALIGN_LEFT, 3, Color(0,10,54,255))
[/lua]

error here;
[lua]
HUDPaint)
[gamemodes\champioboxing\gamemode\cl_init.lua:11] attempt to concatenate global ‘Money’ (a nil value)(Hook: HUDPaint)
[/lua]

full code;
[lua]
function GM:HUDPaint()
draw.SimpleTextOutlined(“Money:$”…Money, “TargetID”, 50,350, Color(0,255,0,255), TEXT_ALIGN_TOP, TEXT_ALIGN_LEFT, 3, Color(0,10,54,255))
if OPT_FIGHT > 0 and MATCH_STARTED == 0 then draw.SimpleTextOutlined("[Matchmaking]: “…OPT_FIGHT…” People are waiting in a match.", “TargetID”, 50,20, Color(255,0,0,255), TEXT_ALIGN_TOP, TEXT_ALIGN_LEFT, 3, Color(0,100,150,255))
draw.SimpleTextOutlined(“Welcome to Champion Fighter Alpha testing! Report bugs to Jayzor!”, “TargetID”, 200,650, Color(255,0,0,255), TEXT_ALIGN_TOP, TEXT_ALIGN_LEFT, 3, Color(0,100,150,255))
end
end
[/lua]

Can you show the usermessage code?
Otherwise you’re only telling us that you haven’t defined the variable Money

Serverside:
[lua]
function statumsg (ply)
umsg.Start(“checkmoney”, ply)
umsg.Long(ply.Money)
umsg.End()
end
[/lua]

Clientside
[lua]
local function checkdatumsg(um)
Money = um:ReadLong()
end
usermessage.Hook(“checkmoney”,checkdatumsg)
[/lua]

In case that usermessage isn’t getting sent when the player joins, you could do (Money or “0”) in the HUDPaint line.

That didn’t work either… :confused:

You’re saying that this:

[lua]
draw.SimpleTextOutlined(“Money:$”…(Money or “0”), “TargetID”, 50,350, Color(0,255,0,255), TEXT_ALIGN_TOP, TEXT_ALIGN_LEFT, 3, Color(0,10,54,255))
[/lua]

Didn’t work?

Whoops, did it wrong. No errors but now it’s staying at zero even when I give myself money.

Then your code for adding money is bad. It’s only 0 when Money is nil.

The thing is it shows up when I check for it in the chat box…

Money is only being defined in the usermessage hook.

Just make a
[lua]local Money = 0[/lua]
outside of any functions in the hud file.

I got it guys! Thanks anyway, I needed to use a NWInt.