• DarkRP attempting to concatenate a nil value
    2 replies, posted
Okay, so, I'm making a very simple HUD for DarkRP (because I'm learning Lua, and I can't necessarily go beyond what I'm doing) and when I draw the text for Salary, it gave me an error saying it can't concatenate a nil value. [CODE] draw.DrawText ( "Salary: ".."$"..LocalPlayer():getDarkRPVar( "salary" ), "DermaDefaultBold", ScrW() - 1530 + 2, ScrH() - 130 + 2, Color (50, 255, 0, 255) ) [/CODE]
In some cases, the player's salary might not exist. An example is when they have just joined the game. Replace [code] LocalPlayer():getDarkRPVar( "salary" ) [/code] with [code] ( LocalPlayer():getDarkRPVar( "salary" ) or "" ) [/code] What this does is check if the salary is nil. If it is, an empty string is used instead.
[QUOTE=Bo98;46764396]In some cases, the player's salary might not exist. An example is when they have just joined the game. Replace [code] LocalPlayer():getDarkRPVar( "salary" ) [/code] with [code] ( LocalPlayer():getDarkRPVar( "salary" ) or "" ) [/code] What this does is check if the salary is nil. If it is, an empty string is used instead.[/QUOTE] Thank you very much!
Sorry, you need to Log In to post a reply to this thread.