(I am using SimplePath but I can make my own if needed)
pretend the appearances of the zombies are actual zombies
I am making a zombie hoard game which I plan to have a ton of zombies for,
the problem is I’m trash with AIs so the zombies stick into a stack like this:
And I saw this post and superalp1111’s 4th idea of zombie teams seemed to be the best for it but I dont know where to start and how I would go about doing this.
Idea:
- each team is a pair of 6 theres one leader
- only one team attacks a player at a time and the other zombies stick behind the team
- The followers of the leader follow their respective leaders
This is what I have so far and I just want a pointer on how to begin.
(In serverScriptService):
local ss = game:GetService("ServerStorage")
local ais = ss:WaitForChild("AIs")
local SimplePath = require(game:GetService("ReplicatedStorage"):WaitForChild("modules"):WaitForChild("SimplePath"))
local ragdoll = require(game:GetService("ServerScriptService"):WaitForChild("modules"):WaitForChild("Ragdoll"))
local ai = require(game:GetService("ReplicatedStorage"):WaitForChild("modules"):WaitForChild("AImodule"))
-- handle all the zombies and control them all with this script
-- only 6 will attack while the others stay back and wait
local attackingZombies = nil
local zombieTeams = {}
local zombiePaths = {}
local zombieDiedConns = {}
local function setUpZombie(char)
local hum = char:WaitForChild("Humanoid")
zombiePaths[char] = SimplePath.new(char)
zombieDiedConns[char] = hum.Died:Connect(function()
if zombiePaths[char] then
zombiePaths[char]:Stop()
zombiePaths[char]:Destroy()
zombiePaths[char] = nil
end
if attackingZombies then attackingZombies[char] = nil end
ragdoll.Ragdoll(char)
zombieDiedConns[char]:Disconnect()
zombieDiedConns[char] = nil
task.wait(2)
char:Destroy()
end)
end
local function spawnAIs(amount)
local leader
for i = 0, amount do
local baseplateSize = workspace.Baseplate.Size
local zombie = ss.Zombies.Zombie:Clone()
if leader == nil then leader = zombie zombieTeams[zombie] = {} else -- if there is no leader than create a empty table with the leaders instance
table.insert(zombieTeams[leader], zombie)
end
setUpZombie(zombie)
local x = math.random(-(baseplateSize.X/8), (baseplateSize.X/8)) -- X 8 because these are just temporary and I want them to spawn close
local z = math.random(-(baseplateSize.Z/8), (baseplateSize.Z/8))
zombie.HumanoidRootPart.Position = Vector3.new(x, workspace.Baseplate.Position.Y + 10, z)
zombie.Parent = workspace.Zombies
task.wait()
end
end
task.wait(3)
spawnAIs(6) -- spawns 6 zombies which are all in one team with one leader
while true do
for zombie, path in pairs(zombiePaths) do
local eChar = ai.GetNearest(zombie.HumanoidRootPart) -- gets nearest character
if eChar and zombiePaths[zombie] then -- if a character is found and if the zombie has a path (from simple path)
spawn(function()
path:Run(eChar.HumanoidRootPart)
end)
end
end
task.wait()
end
Thanks in advanced!