Lua Help Please!

So i have this code for Gmod

concommand.Add( “MyCommand”, myFunc )

function myfunc(name)
Msg("Hello there "…name)
end

myfunc(“Jeff”)
myfunc(“Josh”)
myfunc(“Alan”)
myfunc(“Andrew”)
myfunc(“Ryan”)

Could someone please tell me why it does not work?

Thanks

Because you’re defining the function after the concommand.Add

Yes but even if i type lua_openscript command.lua it still dosn’t work?

No no.

You are setting up the function after the console command so when you call the command, the command doesn’t know where the function is.

When you make a hook or console command, the command has to come after the function so it has something to reference the command to.

Thanks