Lua problems

hi, i am new to this site, and im not the best luaer ever but i know how to do some basic thing, but anyways i am trying to make a weapon that will spawn 4 zombies difrent zombie (headcrab, fast, zombie, torso), and one random of thos 4, total of 5 zombie.
and the lua i am working on will only spawn one zombie, im sorry if i am posting this in wrong section or i am doing anything wrong, but i am despret to get this fix atm =P, im tierd of constantly failing.

–Table
local table = table;

–What zombies to spawn.
SWEP.AllZombie = {
“npc_zombie”,
“npc_zombie_torso”,
“npc_headcrab”,
“npc_fastzombie”
};
SWEP.Randomzombie = {
“npc_zombie”,
“npc_zombie_torso”,
“npc_headcrab”,
“npc_fastzombie”
};

–What Primary Fire you do.
function SWEP:PrimaryAttack()
local weaponTrace = self.Owner:GetEyeTrace();
local traceEntity = weaponTrace.Entity;
local tracePos = weaponTrace.HitPos + self.Owner:GetAimVector() * -6;
local traceAngle = weaponTrace.HitNormal:Angle();
local Zombie = table.Random(self.AllZombie);
local zRandom = table.Random(self.Randomzombie);

		if ( !SERVER ) then return end
   
	if ( weaponTrace.HitWorld ) then
            local Entity = ents.Create(Zombie);
			        Entity:SetPos(tracePos);
                                    Entity:SetHealth(120);
                                    Entity:SetAngles(Angle(0, 90, 0));
            local Entity = ents.Create(zRandom);
			        Entity:SetPos(tracePos);
                                    Entity:SetHealth(120);
                                    Entity:SetAngles(Angle(0, 90, 0));
		         Entity:Spawn();
		         self:Remove();
    end

end;

here is the lua im wroking on, i know that the table.Random is wrong, but i dont know what to replace it wiht =P. it will be really good if someone could help me wiht this =P.


(User was banned for this post ("Undescriptive thread title" - Gran PC))

Do you get any errors in the console with this?

no, no errors.

i shot my pistol one zombie spawns. but what i want is i shoot my pistol and 5 zombie spawn (every one in the allzombie tabel and 1 random from the Randomzombie table),
when i shot the ground now with the gun it only pick out one random of the allzombie table =C

as far as I can see, you’re only creating one zombie.

Your lau is flawed.

i know im only creating one zombie, i wanna know how i make it so i create more then one =P

I’ve never tried making a SWep before, but just a guess would be take out the random zombie table, and all the other variables dealing with randomzombie:



--Table
local table = table;

--What zombies to spawn.
SWEP.AllZombie = {
"npc_zombie",
"npc_zombie_torso",
"npc_headcrab",
"npc_fastzombie"
};

--What Primary Fire you do.
function SWEP:PrimaryAttack()
local weaponTrace = self.Owner:GetEyeTrace();
local traceEntity = weaponTrace.Entity;
local tracePos = weaponTrace.HitPos + self.Owner:GetAimVector() * -6;
local traceAngle = weaponTrace.HitNormal:Angle();
local Zombie = table.Random(self.AllZombie);

if ( !SERVER ) then return end

if ( weaponTrace.HitWorld ) then
local Entity = ents.Create(Zombie);
Entity:SetPos(tracePos);
Entity:SetHealth(120);
Entity:SetAngles(Angle(0, 90, 0));
Entity:SetPos(tracePos);
Entity:SetHealth(120);
Entity:SetAngles(Angle(0, 90, 0));
Entity:Spawn();
self:Remove();
end
end;


Like I said, I’ve never tied this before, and it’s just a suggestion.

nah that wont work =P, but thx you