Can anyone help me i am making a tower defence simulator and when i spawn more than 1 wave it gives me an error "attempt to index number with 'Start' "
i have a part in the workspace in my folder 'Grassland' which is my map and this is my wave code
local mob = require(script.Mob) local map = workspace.Grassland
for wave=1,2 do print("WAVE STARTING:", wave)
if wave <= 1 then mob.Spawn("Zombie", 3 * wave, map) elseif wave <= 2 then mob.Spawn("Zombie", 6, wave, map) mob.Spawn("FastZombie", 3, wave, map) elseif wave == 2 then mob.Spawn("Zombie", 100, map) end repeat task.wait(1) until #workspace.Mobs:GetChildren() == 0 print("WAVE ENDED") task.wait(13)
end
and this is my main script
local PhysicsService = game:GetService("PhysicsService") local ServerStorage = game:GetService("ServerStorage") local mob = {}
function mob.Move(mob, map) local humanoid = mob:WaitForChild("Humanoid") local waypoints = map.Waypoints
for waypoint=1, #waypoints:GetChildren() do humanoid:MoveTo(waypoints[waypoint].Position) humanoid.MoveToFinished:Wait() end mob:Destroy()
end
function mob.Spawn(name, quantity, map) local mobExists = ServerStorage.Mobs:FindFirstChild(name)
if mobExists then for i=1, quantity do task.wait(0.5) local newMob = mobExists:Clone() newMob.HumanoidRootPart.CFrame = map.Start.CFrame newMob.Parent = workspace.Mobs newMob.HumanoidRootPart:SetNetworkOwner(nil) for i, object in ipairs(newMob:GetDescendants()) do if object:IsA("BasePart") then PhysicsService:SetPartCollisionGroup(object, "Mob") end end coroutine.wrap(mob.Move)(newMob, map) end else warn("Request mob doesnt exists", name) end
end
return mob