Zombie Spawning Problems

What i’m trying to do is get a zombie, and also get its spawn at the same time, and to create a new zombie after that, I didn’t want to make a script for each one, which could cause problems later on.

Init.lua


42: SpawnLocation = ents.FindByName("ZombieSpawn")
43: Zombie = {}
44: 
45: function SpawnZ()
46: 	for I = 1, #SpawnLocation, 1 do
47: 		Zombie* = ents.Create("npc_zombie")
48: 		Zombie*:SetPos(SpawnLocation*:GetPos())
49: 		Zombie*:Spawn()
50: 	end
51: end
52: 
53: function NPCDied(Victim, Killer, Weapon)
54: 	if Victim:GetClass() == "npc_zombie" then
55: 		for i = 1, #Zombie, 1 do
56: 			if Zombie*:Health() == 0 then
57: 				Msg("Zombie Died, Making Another!
")
58: 				Zombie*
59: 				Zombie*:SetPos(SpawnLocation*:GetPos())
60: 				Zombie*:Spawn()
61: 			end
62: 		end
63: 	end
64: end

Output Error


[ERROR] gamemodes/solitude/gamemode/init.lua:59: '=' expected near 'Zombie'
  1. unknown - gamemodes/solitude/gamemode/init.lua:0

Couldn't Load Init Script: 'solitude/gamemode/init.lua'
[

[editline]25th November 2012[/editline]

Does really no one know?

You just put a random “Zombie*” in the middle of your script. I’m going to take a guess and say that’s the issue.

Zombie* Equals “ents.Create(“npc_zombie”)”

The purpose to that was to create another zombie, but on the same value. I could try to initialize the value to the same thing, it wouldn’t matter.

[editline]25th November 2012[/editline]

That problem was fixed, but now some other issues.

Output Error



[ERROR] gamemodes/solitude/gamemode/init.lua:53: attempt to get length of global 'Zombie' (a userdata value)
  1. v - gamemodes/solitude/gamemode/init.lua:53
   2. unknown - lua/includes/modules/hook.lua:75


Init.lua


42: SpawnLocation = ents.FindByName("ZombieSpawn")
43: Zombie = {}
44: 
45: for I = 1, #SpawnLocation, 1 do
46: 		Zombie* = ents.Create("npc_zombie")
47: 		Zombie*:SetPos(SpawnLocation*:GetPos())
48: 		Zombie*:Spawn()
49: end
50: 
51: function NPCDied(Victim, Killer, Weapon)
52: 	if Victim:GetClass() == "npc_zombie" then
53: 		for i = 1, #Zombie, 1 do
54: 			if Zombie*:Health() == 0 then
55: 				Msg("Zombie Died, Making Another!
")
56: 				Zombie* = ents.Create("npc_zombie")
57: 				Zombie*:SetPos(SpawnLocation*:GetPos())
58: 				Zombie*:Spawn()
59: 			end
60: 		end
61: 	end
62: end

I know that on Line 53, that it says nil, it’s because the zombies arn’t spawning.

[editline]25th November 2012[/editline]

Found the problem, the values apperently need to be inside the function.