Hi everyone! So I was working on a script from a tutorial and I came across a problem where slower zombies/mobs would skip waypoints if they were too slow, causing them to go off track. (for context I’m making a Tower Battles esc game) Here’s the script:
local mob = {}
local PhysicsService = game:GetService(“PhysicsService”)
local ServerStorage = game:GetService(“ServerStorage”)function mob.Move(mob, map)
local humanoid = mob:WaitForChild(“Humanoid”)
local waypoints = map.Waypointsfor waypoint=1, #waypoints: GetChildren() do
humanoid:MoveTo(waypoints[waypoint].Position)
humanoid.MoveToFinished:Wait(.1)
endmob: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 = map.Mobfor 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
Overall, I’m just confused and annoyed by this issue, slower mobs are the problem. If anyone could help that would be greatly appreciated!