So i have an issue where i want to tell multiple npcs to move with one script
they keep moving 1 after another and not together
My goal is to make all npcs move together into 1 position
function UnitControl:Move(pos: Vector3)
for i,unit in pairs(ControlledUnits) do
unit.Humanoid:MoveTo(pos)
path:ComputeAsync(unit.PrimaryPart.Position,Vector3.new(pos.X,unit.PrimaryPart.Position.Y,pos.Z))
if path.Status ~= Enum.PathStatus.NoPath then
local points = path:GetWaypoints()
if points and points[3] then
print(3)
unit.Humanoid:MoveTo(points[3].Position)
end
end
end
end
function UnitControl:Move(pos: Vector3)
for i, unit in pairs(ControlledUnits) do
coroutine.wrap(function()
unit.Humanoid:MoveTo(pos)
path:ComputeAsync(unit.PrimaryPart.Position, Vector3.new(pos.X, unit.PrimaryPart.Position.Y, pos.Z))
if path.Status ~= Enum.PathStatus.NoPath then
local points = path:GetWaypoints()
if points and points[3] then
print(3)
unit.Humanoid:MoveTo(points[3].Position)
end
end
end)()
end
end