Execute console commands using lua

I’m trying to make a test swep but i have a problem, what command should i use in the swep so that i can run a console command? lets say that i want to execute “sbox_maxballoons 10” when i press “PrimaryAttack”, what should i type under:


 function SWEP:PrimaryAttack() 

**[Game.ConsoleCommand

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

Thanks!

No problem.

But i still got one problem…
When i deploy the swep the command works but when i’m trying to change to a diffrent swep i can’t, i get an error on line 49, here’s then code:


 
function SWEP:Deploy()
self.Owner:SetRunSpeed(4250)
self.Owner:SetWalkSpeed(1500)
self.Owner:SetJumpPower(400)
game.ConsoleCommand("host_timescale 0.1
")
end

function SWEP:Holster()
self.Owner:SetRunSpeed(500)
self.Owner:SetWalkSpeed(300)
self.Owner:SetJumpPower(200)
game.ConsoleCommand("host_timescale 1
") <-- line 49
end


do you find anything wrong with it?

Return true in SWEP.Holster after the command.

And whats the error?, Wait. isnt that ran on both client and server? game.ConsoleCommand is a serverside function so add a if SERVER then

^ And this.

Thanks again.