trying to make an npc car shop, won't use the console command.

I"m making an npc car shop but it says buycar is an unknown command. I’ve tried putting it in my gamemode and tried putting it in the entity itself but I still get the same problem. here’s the concommand:
[lua]function CarShop(p,c,a)
i = tonumber(a[1])
if i and cars* and p:GetMoney()>=cars*.price then
local ent1 = ents.Create(cars*.Car)
ent1:SetPos(p:GetPos() + Vector(75,0,10))
p:ChatPrint(“Come back when you can afford this”)
concommand.Add(“buycar”, CarShop )[/lua]

here’s the cars table:
[lua]cars = {
Car = “jalopy”,
Price = 1850,
model = “models/vehicle.mdl”,

the console command is used by clicking on an icon which is clientside. I have no idea what the problem is though.

I based the npc off this tutorial:

Hey, I know like nothing about lua but iv’e been looking at this same tut and from what ive read in others you could try this, see if it works:

concommand.Add( “console_command_here”, function_here )

So basically change the “console_command_here” to whatever you want the Console Command to be, keep the “”, and then do the same for function_here as it is.

Hope that helps, if it doesnt ill look back here soon :smiley:

@xomaxhox that won’t help the OP at all.

@Carmine Make sure you’re running the concommand code serverside and that it’s actually running! Also check for errors.

For this line:
[lua]if i and cars* and p:GetMoney()>=cars*.price then[/lua]

Should it not be cars*.Price with a capital P?

how did I miss that? I’ll fix it and see if it works.