How to call weapon in a function?

Hello I am trying to formulate a script that prints the world model of the current weapon you have out. Here’s what I have but I don’t think it’ll work because of weapon not being defined in the function.



concommand.Add( "wmprint", function( ply, cmd, args )
	ply:ChatPrint("Weapon model printed.")
	print( 	Weapon:GetWeaponWorldModel() )
end )


You could use

Player:GetActiveWeapon.



concommand.Add( "wmprint", function( weapon, ply, cmd, args )
	print( ply:GetActiveWeapon():GetWeaponWorldModel() )
	ply:ChatPrint("Weapon model printed in console.")
end )


like this?

[editline]26th July 2017[/editline]




[ERROR] gamemodes/darkrp/gamemode/modules/sv_drawworldmodel.lua:2: attempt to index a string value with bad key ('GetActiveWeapon' is not part of the string library)
  1. error - [C]:-1
   2. __index - lua/includes/extensions/string.lua:297
    3. unknown - gamemodes/darkrp/gamemode/modules/sv_drawworldmodel.lua:2
     4. unknown - lua/includes/modules/concommand.lua:54


This is the error i get with the code above

Because “ply” is a string. Read up on

concommand.Add.

Hmm alright. What should I use instead?