• Lua problem
    4 replies, posted
Trying to delete all zombies on the map with a concommand and all I get is a error: attempt to call method 'Remove' (a nil value) [QUOTE]function KillZombies() ents.FindByName('npc_zombie') end concommand.Add('zombies_kill', KillZombies)[/QUOTE]
That error doesn't match your code. But anyway, this is what it should look like: [code]concommand.Add("zombies_kill", function() local tZombies = ents.FindByClass("npc_zombie") for i = 1, #tZombies do tZombies[i]:Remove() end end )[/code]
[QUOTE=GoldenLeopard;50539603]Trying to delete all zombies on the map with a concommand and all I get is a error: attempt to call method 'Remove' (a nil value)[/QUOTE] Dont use ents.FindByName('npc_zombie'), Use ents.FindByClass('npc_zombie') That returns a table so store it in a var like this [CODE]local x = ents.FindByClass('npc_zombie') Then to remove them all loop over it and call remove for k ,v in pairs(x) do v:Remove() end[/CODE]
Ninja'd, Guess its karma right code_gs? xD
thx guys
Sorry, you need to Log In to post a reply to this thread.