Why is my bot stopping every finished point

The issue is that the humanoid is moving unsmoothly and idk why.
And i suspect this function (MovingTo) as it’s responsible for moving the character.

Invoking script

local ActionModule = require(script:WaitForChild("ActionModule"))

while wait() do
	local PlayerTarget = workspace:WaitForChild("fgfbfrj")
	ActionModule:SetNewStatus("MovingTo","Destination",PlayerTarget.PrimaryPart.Position)
end

Special data

local SpecialData = {
	Destination = HumanoidRootPart.Position,
	Target = nil,
	FinishedPath = true,
	Hiding = false,
	Fighting = false,
    ComputingPath = false,
	Path = {
		Status = Enum.PathStatus.NoPath,
		NewPath = true,
		Waypoints = {}
	},
	WalkIndex = 2,
}

There’s rest of the script

MovingTo = function()
		if SpecialData.FinishedPath then
			local FinishedMovement = false
			coroutine.resume(coroutine.create(function()
				SpecialData.FinishedPath = false
				_CreatePath(HumanoidRootPart.Position,SpecialData.Destination)
				local function IsInterrupted()
                   return MonitorModule:FindGrenade() or MonitorModule:CharacterDamaged()
				end
				
				local Path = SpecialData.Path.Waypoints
				local Success = SpecialData.Path.Status
				if Success == Enum.PathStatus.Success then
					if SpecialData.Path.NewPath then
						SpecialData.WalkIndex = 2
						SpecialData.Path.NewPath = false
					else
						SpecialData.WalkIndex += 1
					end
					local WalkIndex = SpecialData.WalkIndex
					local Connection = nil
					local Destination = Path[WalkIndex].Position or HumanoidRootPart.Position
					Humanoid:MoveTo(Destination)
					Connection = Humanoid.MoveToFinished:Connect(function()
						if not FinishedMovement then
							FinishedMovement = true
						end
						Connection:Disconnect()
					end)
					while (wait() and not FinishedMovement) do
						if IsInterrupted() then
							FinishedMovement = true
						end
					end
				end
				print("finished")
				SpecialData.FinishedPath = true
			end))
		end
	end,

robloxapp-20211002-0901021.wmv (1.5 MB)

honestly my AI’s are having the same issue, I tried to split them into different threads, helped a little but i’m confused as well.

Things i’ve done to make sure bots are working smoothly;
Set the network owner of the object to the server, (bot.PrimaryPart:SetNetworkOwner(nil))
1 Thread for 5 Bots
5 Threads working under a mutex manager

if you find any fix please inform me ! ~ Async

1 Like