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
It seems in your first code mob.Spawn
has 3 arguments but in the module script you have no argument to define that. I believe that the 2nd argument would be how many mobs are spawning. In that case, I would say a code that might work would be this:
function mob.Spawn(name, count, map) local mobExists = ServerStorage.Mobs:FindFirstChild(name) if mobExists then for i=1,count do 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 end