I have been working on this tower defense system for a couple hours today and I realized a problem. The normal and fast enemies complete the little test map I made at the correct position, but no such luck for the slows. I don’t have the foggiest idea why the despawn so far from the end point.
robloxapp-20220130-1327078.wmv (2.8 MB)
local serverStorage = game:GetService("ServerStorage")
local physicsService = game:GetService("PhysicsService")
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(0.1)
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 = game.Workspace.Grassland.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("Requested mob is not exist:"..name)
end
end