I am trying to make the zombies from my TD game move along the path but the slow ones go any way they want
I’ve tried moving the points where they have to reach but they just go to the furthest point then somehow get destroyed
Here’s a video: Pathfinding Bug - YouTube
1st script used:
local mob = require(script.Mob)
local map = workspace.LumberjackVillage
for i=1, 5 do -- WAVE 1
mob.Spawn("Normal", map)
task.wait(0.5)
end
for i=1, 5 do -- WAVE 2
mob.Spawn("Speedy", map)
task.wait(0.5)
end
for i=1, 5 do -- WAVE 3
mob.Spawn("Slow", map)
task.wait(0.5)
end
2nd script used:
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, map)
local mobExists = ServerStorage.Mobs:FindFirstChild(name)
if mobExists then
local newMob= mobExists:Clone()
newMob.Parent = workspace
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)
else
warn("Requested mob does not exist:", name)
end
end
return mob```