Can't run a shared method while placed in cl_init?

Hey guys, I am making this gamemode for learning purposes, and, I am making a derma weapon selection menu right now. But theres something strange going on. I got this piece of code:[lua]function WeaponSelectMenu()
local WepMenu = vgui.Create(“DPanel”)
WepMenu:SetTitle(“Weapon Menu”)
WepMenu:SetSize( 200, 400 )
WepMenu:SetVisible( true )

local M14Button = vgui.Create("DButton")
M14Button:SetParent( WepMenu )
M14Button:SetText( "M14" )
M14Button:SetPos( 50, 50 )
M14Button:SetSize( 80, 40 )
M14Button.DoClick = function()

local AK47Button = vgui.Create("DButton")
AK47Button:SetParent( WepMenu )
AK47Button:SetText( "AK47" )
AK47Button:SetPos( 50, 100  )
AK47Button:SetSize( 80, 40 )
AK47Button.DoClick = function()

concommand.Add(“weaponmenu”, WeaponSelectMenu)[/lua]

And, when my game starts, it runs the command weaponmenu, so it starts up when you spawn, but then, when the derma menu popped up, it gives me this error in console: [gamemodes\learning\gamemode\cl_init.lua:34] attempt to call method ‘SetTitle’ (a nil value)

then, I deleted that line, seeing if I maybe did something wrong with the SetTitle method.
Now, when it starts up, the derma doesnt have a title, but it does have the 2 buttons, where they are supposed to be. But when I click one of the buttons, it gives me this error: [gamemodes\learning\gamemode\cl_init.lua:45] attempt to call method ‘ConCommand’ (a nil value)

And i’m very sure “ply:ConCommand” is a clientside function, so I have no idea why it isn’t calling it. Please some help?

First of all, you’ve mixed together DPanel and DFrame, it should be DFrame.
Secondly, use RunConsoleCommand(“bla”) instead of ply:ConCommand(“bla”) on singleplayer. The fact why “ply:ConCommand” doesn’t work, is because you never define ply.
Third, have some prefix for your weapon commands. Having only “m14” is bad practice and might hunt you later.

Sorry for hijacking this thread but it could help him aswell.

Is there a better way of sending something to the server, such as my derma wants me to equip something so it sends it to server to equip it.

Is there a good way to do this?

Console commands are the way to send stuff to the server, in fact I dunno if there is another way, datastream uses console commands so it would be like the same shit.

Ok, so just encrpyt my console commands in a way, such as to equip a weapon have something like

w3az0cp - equipmentadd
12 - weapon id

so the server and client both know the ids and console commands and they then stay secure to stop people abusing him.

Also, server verification will hopefully work for me aswell.

No, add checks to them, like if they don’t have enough money.

You can easily go read the clientside files and find them, making them random will only confuse you the coder.

Fair enough, thank you for this.