local mob = require(script.Mob)
local map = workspace.Grassland
for wave=1, 5 do
print("WAVE STARTING:", wave)
if wave < 5 then
mob.Spawn("Zombie", 3 * wave, map)
elseif wave == 5 then
mob.Spawn("Zombie", 100, map)
end
print("WAVE ENDED")
task.wait(1)
end
Here is my coding for spawning the monsters:
local ServerStorage = game:GetService("ServerStorage")
local mob = {}
function mob.Move(mob, map)
local humanoid = mob:WaitForChild("Humanoid")
local waypoints = game.Workspace.WayPoints
for waypoint=1, #waypoints:GetChildren() do
humanoid:MoveTo(waypoints[waypoint].Position)
humanoid.MoveToFinished:Wait()
end
mob:Destroy()
end
function mob.Spawn(name, map)
local mobExists = ServerStorage.Mobs:FindFirstChild(name)
if mobExists then
local newMob = mobExists:Clone()
newMob.HumanoidRootPart.CFrame = game.Workspace.Start.CFrame
newMob.Parent = workspace
coroutine.wrap(mob.Move)(newMob, map)
else
warn("requested mob does not exist:", name)
end
end
return mob

1 comment
There seem to be inconsistencies in your code. In your first code snippet, mob.Spawn has 3 arguments, whereas in the second code snippet it has 2.