Having an Error trying to Give Weapons!

Hey im trying to make a button on the derma menu to give player a certain weapon. There is an error saying its a nil value which im confused why :stuck_out_tongue: But i may have over looked something, or thought twice about it.
THE CODE



//Buttons
		local DermaButton = vgui.Create( "DButton" )
		DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
		DermaButton:SetText( "Assault" )
		DermaButton:SetPos( 25, 50 )
		DermaButton:SetSize( 150, 50 )
		DermaButton.DoClick = function ()
		ply:Give( "cs_weapon_m4a1" )
		end


THE ERROR



[ERROR] gamemodes/dontneedtoknowyet/gamemode/cl_init.lua:29: attempt to call method 'Give' (a nil value)
  1. DoClick - gamemodes/dontneedtoknowyet/gamemode/cl_init.lua:29
   2. unknown - lua/vgui/dlabel.lua:206


Line 29 is



ply:Give( "cs_weapon_m4a1" )


Thank you for the help :slight_smile:

PLAYER:Give() doesn’t exist clientside. You’ll need to network it somehow. I.E. Net Messages or ConCommands.

-ninja’d-

Ok thanks ill look into that :slight_smile:

[editline]29th August 2014[/editline]

Ok now it wont give the weapon. It doesnt put any errors. I have it run a command when the button is pressed



//Buttons
		local DermaButton = vgui.Create( "DButton" )
		DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
		DermaButton:SetText( "Assault" )
		DermaButton:SetPos( 25, 50 )
		DermaButton:SetSize( 150, 50 )
		DermaButton.DoClick = function ( ply )
		print( "class1" )
		end


Then that command gives the weapon



//Console Commands
concommand.Add( "class1", vcg_assault )
//Commands Functions
function vcg_assault()
	ply:Give( "weapon_cs_m4" )
end



But it will not give the weapon. The weapon is in the entities/weapons folder.