ConsoleCommand error

I’m getting this error, Cannot figure out the problem

autorun/client/vgui_banmenu.lua:45: attempt to call field ‘ConsoleCommand’ (a nil value)

Here is the code

[lua]
–[[
Product: Source Core.
Name: Visual Graphic Interface.
Use: Visual interface.
–]]

// Include start
// Include end

// Script Start
if (CLIENT) then
function BanMenu()
if (LocalPlayer():IsSuperAdmin()) then
BanFrame = vgui.Create( “DFrame” )
BanFrame:SetSize( 200, 200 )
BanFrame:Center()
BanFrame:SetTitle( “BanMenu” )
BanFrame:SetDraggable( true )
BanFrame:ShowCloseButton( true )
BanFrame:MakePopup()

local CurrentFreq = vgui.Create( "DLabel", BanFrame )
CurrentFreq:SetPos( 20, 30 )
CurrentFreq:SetText( "Steam ID" )
CurrentFreq:SetFont( "TargetID" )
CurrentFreq:SizeToContents()
CurrentFreq.Think = function()
	CurrentFreq:SetText( "Source.Core.Bans" )
end
	local TimeTextEntry = vgui.Create( "DTextEntry", BanFrame )
TimeTextEntry:SetPos( 10, 75 )
TimeTextEntry:SetSize( 80, 20 )
TimeTextEntry:SetText( "" )

local BanTextEntry = vgui.Create( "DTextEntry", BanFrame )
BanTextEntry:SetPos( 10, 110 )
BanTextEntry:SetSize( 80, 20 )
BanTextEntry:SetText( "" )

local ConfirmButton = vgui.Create( "DButton", BanFrame )
ConfirmButton:SetPos( 50, 150 )
ConfirmButton:SetSize( 50, 20 )
ConfirmButton:SetText( "Execute" )
ConfirmButton.DoClick = function()
	game.ConsoleCommand( "banid " .. TimeTextEntry:GetValue() .. BanTextEntry:GetValue() .. " Source Core : Banned!" .. "

" )
end
end
end
end
concommand.Add( “BanMenu”, BanMenu ) [/lua]

Can anyone help me fix this…?

It’s because you’re calling it clientside and it should be executed serverside.

How can i call that one function server-side? Because the script is required serverside? Or can i have another method around this?

First using a bit of logic. Anybody that connects to a server can run any clientside code. Now it makes sence that running banid has to be made on the server doesn’t it? :smile:

So what you need to do is have the client run a function on the server ( trough RunConsoleCommand() ) that will (if said player is an admin) execute that console command.