I am running this on nutscript and before I spawn a character I get a lua error
[ERROR] gamemodes/nutscript/gamemode/core/libs/cl_hud.lua:108: attempt to index a nil value
1. v - gamemodes/nutscript/gamemode/core/libs/cl_hud.lua:108
2. unknown - lua/includes/modules/hook.lua:84
Its because its trying to get the amount of money the character has but theres no character loaded. How do I makes this work
local money = LocalPlayer():getChar():getMoney()
[code]
function hud()
local health = LocalPlayer():Health() or 0
local armor = LocalPlayer():Armor() or 0
local name = LocalPlayer():Name()
local stm = LocalPlayer():getLocalVar("stm", 0)
local money = LocalPlayer():getChar():getMoney() // THIS LINE HERe
draw.RoundedBox(15,0,ScrH() - 220,490,170,Color(234,94,0))
surface.SetDrawColor( 255, 255, 255, 255 )
//Borders
draw.RoundedBox( 0, 0, ScrH() - 70, 490, 5, Color(0, 0, 0) )
draw.RoundedBox( 0, 0, ScrH() - 210, 490, 5, Color(0, 0, 0) )
// Health
draw.RoundedBox(0, ScrW() - 1320, ScrH() - 90,100, 20, Color( 250, 0, 0, 100 ) )
draw.RoundedBox(0,ScrW() - 1320,ScrH() - 90,health,20,Color(255,0,0))
draw.DrawText( "Health", "TargetID", ScrW() - 1275, ScrH() - 90, Color( 0, 0, 0, 250 ), TEXT_ALIGN_CENTER )
//Armor
draw.RoundedBox(0, ScrW() - 1160, ScrH() - 90,100, 20, Color( 0, 0, 240, 100 ) )
draw.RoundedBox(0,ScrW() - 1160,ScrH() - 90,armor,20,Color(0,0,250))
draw.DrawText( "Armor", "TargetID", ScrW() - 1120, ScrH() - 90, Color( 0, 0, 0, 250 ), TEXT_ALIGN_CENTER )
//TEXT
draw.DrawText( "Time Played", "TargetID", ScrW() - 1275, ScrH() - 66, Color( 0, 0, 0 ), TEXT_ALIGN_CENTER )
draw.DrawText( "SeriousRP", "Cool", ScrW() - 100, ScrH() - 100, Color( 0, 0, 0, 250 ), TEXT_ALIGN_CENTER )
//name
draw.DrawText( "Name:", "TargetID", ScrW() - 1210, ScrH() - 180, Color( 0, 0, 0, 250 ), TEXT_ALIGN_CENTER )
draw.DrawText( name, "TargetID", ScrW() - 1135, ScrH() - 180, Color( 0, 0, 0, 250 ), TEXT_ALIGN_CENTER )
//money
draw.DrawText( "Money: $", "TargetID", ScrW() - 1210, ScrH() - 160, Color( 0, 0, 0, 250 ), TEXT_ALIGN_CENTER )
draw.DrawText( money, "TargetID", ScrW() - 1135, ScrH() - 160, Color( 0, 0, 0, 250 ), TEXT_ALIGN_CENTER )
//stam
draw.RoundedBox(0, ScrW() - 1010, ScrH() - 90,100, 20, Color( 0, 250, 0, 100 ) )
draw.RoundedBox(0,ScrW() - 1010,ScrH() - 90,stm,20,Color(0,250,0))
draw.DrawText( "Stamina", "TargetID", ScrW() - 970, ScrH() - 90, Color( 0, 0, 0, 250 ), TEXT_ALIGN_CENTER )
//test
surface.DrawCircle( ScrW() - 1298, ScrH() - 145, 55, Color(0,0,0,255) )
end
hook.Add("HUDPaint", "thehud", hud)
[/code]
Would be nice if you pointed out the line which the error is referring to.
The lua you posted is not 108 lines or more.
Second, the error you're getting does not exist within the code you have provided.
Please post the full lua code for that file.
Sorry I forgot Fixed it its the 6th line
Sorry, you need to Log In to post a reply to this thread.