NPC Creation?




function spawnnpc()
	local testzombie = ents.Create("npc_fastzombie")
	testzombie:SetPos(Vector(0,0,0))
	testzombie:Spawn()
	testzombie:Activate()
end
concommand.Add("spawnnpc", spawnnpc)



why is it, when i open up the game, its not actually creating the command? I assume my function is wrong, but i would like some further explanation why. :stuck_out_tongue:

That code works perfectly for me. It’s probably not being read. Make sure you either placed it into lua/autorun/ or in a server-side file (of a gamemode for instance).

Or you could just put it /lua/ and use lua_openscript in the console.

No, it should work fine. What matters is where are you putting the command? If it’s on the client then it won’t work; it has to be from the server.

forgot to include MAH BAD