How to write the ActiveWeapon?

Hi, me agian, still making a gui. I was wondering how I could go about writing a current weapon.

I tried



ActiveWeapon = LocalPlayer():GetActiveWeapon()
print(tostring(ActiveWeapon))


and that just gave me this.

Weapon [81][weapon_physgun]

So is there anyway to do this? Thanks in advance! :slight_smile:

:GetClass() writes weapon_physgun,
edit:
[LUA]
ActiveWeapon = weapons.GetStored( LocalPlayer():GetActiveWeapon():GetClass() ).PrintName;
[/LUA]

I copy pasted that code, I get a attempt to Index nil value err.



[ERROR] addons/mg's hud/lua/darkrp_modules/hudreplacement/cl_hudreplacement.lua:119: attempt to index a nil value
  1. v - addons/mg's hud/lua/darkrp_modules/hudreplacement/cl_hudreplacement.lua:119
   2. unknown - lua/includes/modules/hook.lua:82


To me, it seems to work for every weapon except for physgun and gravity gun, so I guess you can use this, but it’s not a great solution:
[LUA]
ActiveWeapon = LocalPlayer():GetActiveWeapon():GetClass();
if ( !weapons.GetStored( ActiveWeapon ) ) then
weaponName = ActiveWeapon;
else
weaponName = weapons.GetStored( ActiveWeapon ).PrintName;
end

[/LUA]

then weaponName is either weapon_physgun or for example .357 Magnum

Your beautiful. Thanks so much! SOLVED!