I hope that this is in the right section so please let me know if it isn’t. Anyway I’m new to lua coding and I’m having problems with a timer function. Every time I load the script I get an error saying: “Timer Error: [@lua\includes\extensions able.lua:177] bad argument #2 to ‘random’ (interval is empty)”. Here’s the code:
timer.Create("Spawn", 10, TotalZombies, SpawnNPC) function SpawnNPC() SpawnPoints = ents.FindByName("Zombie_Spawn") //Finds all zombie spawn points (info_targets with the specified name) SpawnPoint = table.Random(SpawnPoints) //Picks a random spawn point for the zombie to spawn at zombie = ents.Create("npc_zombie") zombie:SetPos(SpawnPoint:GetPos()) //Sets the spawn point for the zombie to spawn at zombie:SetName("zombie") zombie:SetKeyValue( 'wakeradius' , '25000.00' ) zombie:SetKeyValue( 'ignoreunseenenemies' , '0' ) zombie:SetKeyValue( 'sleepstate' , '1' ) zombie:Spawn() end
Each time the SpawnNPC function is loaded the error will appear but a zombie will spawn regaurdless of the error which is annoying and when a zombie spawns it just stands there even though the keyvalue was set so they will not ignore unseen enemies and the wake radius is the size of the map (you can look these keyvalues up here under keyvalues: https://developer.valvesoftware.com/wiki/Npc_zombie ). I’m quite sure the crash is just because the zombies don’t move and spawn ontop of eachother because it dosn’t happen when I move them. Is there a better way to make them attack a player anywhere on the map on spawn and not crash the game? And is there any reason for the error and how could I fix it?