So I have ammo working on my darkrp hud but when I die it gives me a script error.
draw.SimpleText(LocalPlayer():GetActiveWeapon():Clip1(), "Trebuchet24", ScrW()*(1750/1920), ScrW()*(1015/1920), Color(255, 255, 255, 255),1,1)
draw.SimpleText(LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType()), "Trebuchet24", ScrW()*(1835/1920), ScrW()*(1015/1920), Color(255, 255, 255, 255),1,1)
if(LocalPlayer():GetActiveWeapon():IsValid()) then
draw.DrawText( "Clip" ,"Trebuchet18", ScrW()*(1750/1920), ScrW()*(1030/1920), Color(255,255,255),1,1)
draw.DrawText( "Reserve" ,"Trebuchet18", ScrW()*(1835/1920), ScrW()*(1030/1920), Color(255,255,255),1,1)
end
draw.SimpleText(LocalPlayer():GetActiveWeapon():Clip1(), "Trebuchet24", ScrW()*(1750/1920), ScrW()*(1015/1920), Color(255, 255, 255, 255),1,1)
draw.SimpleText(LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType()), "Trebuchet24", ScrW()*(1835/1920), ScrW()*(1015/1920), Color(255, 255, 255, 255),1,1)
if (LocalPlayer():GetActiveWeapon():GetPrintName() != nil) then
draw.SimpleText(LocalPlayer():GetActiveWeapon():GetPrintName(), "Trebuchet18", ScrW()*(1800/1920), ScrW()*(985/1920), Color(255, 255, 255, 255),1,1)
end
Thanks for providing the error, although just by looking at it
LocalPlayer():GetActiveWeapon()
This becomes null when you don't have an equipped weapon, verify that the weapon is valid before running that fragment
just a note for the OP, go look up IsValid on the gmod wiki
I have added a line of code that will be under the error but when I die I get this error still.
(LocalPlayer():GetActiveWeapon():Clip1()
Code I added:
if (LocalPlayer():GetActiveWeapon():Clip1() != nil) then
Sorry, you need to Log In to post a reply to this thread.