local ServerStorage = game:GetService("ServerStorage")
local MOB = {}
function MOB.Move(mob, map)
local humanoid = mob:WaitForChild("Humanoid")
local waypoints = workspace.WayPoints
for waypoint=1, #waypoints:GetChildren() do
mob.Humanoid:MoveTo(waypoints[waypoint].Position)
mob.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 = workspace.MAP.ZombieSpawn.CFrame
newMob.Parent = map.Mob
coroutine.wrap(MOB.Move)(newMob, map)
end
else
warn("idk")
end
end
return MOB
You are accessing it as though it is a table and trying to locate a child with the name of an index. You would either need to use a for i, waypoint in pairs(waypoints:GetChildren()) do OR you would need to reference waypoints:GetChildren()[waypoint] in your example above.