(Lua) Button > ConCommand Error

I’m trying to do something as simple as giving a player a Deagle using a button.

[lua]
function window( pl, cmd, args )
Draw shit
end

button = vgui.Create( “DButton”, window );
More draw shit
button:SetText( “Deagle” );
button.DoClick = function( button )
RunConsoleCommand( “givew”, “weapon_deagle” )
end
concommand.Add( “mainmenu”, window )
concommand.Add(“givew”, function(pl, cmd, args) RunConsoleCommand(“give”…args[1]) end) [/lua]

If I click the button that i’ve created, this error comes up,
“Unknown command: giveweapon_deagle”, because of ““give”…args[1]”.

But if I make it something like "give "…args[1] or “give” …args[1], it says this:

“RunConsoleCommand: Command has invalid characters! (give weapon_deagle (’ '))
The first parameter of this function should contain only the command, the second parameter should contain arguments.”

I don’t know how to fix it, and I’ve been trying for hours. It’s really starting to bug me.

Any suggestions? Please? Lol.

The first thing to do is always to look up the function you’re having trouble with in the wiki :
**[G.RunConsoleCommand

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=G.RunConsoleCommand)**

The proper way to write it is : RunConsoleCommand(“give”, args[1])
Just like you seem to be doing above in your code.

You should use Player.Give instead of using the give console command.

[lua]
concommand.Add( “givew”, function( ply, cmd, arg )

ply:Give( arg[1] )

end )[/lua]

I had already tried that, but before it just said “Attempt to call “Give” A nil value” or something like that

EDIT:
Main_Menu.lua:18: attempt to call method ‘Give’ (a nil value)


concommand.Add("givew", function(pl, cmd, args) 

RunConsoleCommand(“give”…args[1])


 end)

[lua]RunConsoleCommand( “give”, args[1] )[/lua]

Should work, as Crazy Quebec mentioned.
And the problem with your original code was that you were directly combining give and the argument, resulting in such commands as “giveweapon_deagle (’ ')”. To do it like you had it originally,

[lua]RunConsoleCommand( "give "…args[1] ) --This does not work.[/lua]

But RunConsoleCommand does not like that. If you wished to use the command as you have it, you would have to use

[lua]LocalPlayer():ConCommand( "give "…args[1] )[/lua]