ive been struggling with this problem for a few days now and I'm lost.This AI has a bad habbit of running into walls and getting stuck in the same spot, never moving again. I don't know why this happens. is there a way to fix this?

local l = script.Parent["Left Leg"]
local t=script.Parent:WaitForChild'Torso'
local b=script.Parent:WaitForChild'Zombie'
local D = false
while wait() do
    pcall(function()
        local z
        local w=math.huge
        for i,v in next,game.Players:GetPlayers() do
            pcall(function()
                local m=(t.Position-v.Character.Torso.Position).magnitude
                if w>m then
                    w=m
                    z=v.Character.Torso
                end
            end)
        end
        for i,v in next,game:GetService'PathfindingService':ComputeRawPathAsync(t.Position, z.Position, 500):GetPointCoordinates() do
            b:MoveTo(v)
		if t.Position.Y < (v.Y - 2) then
		if (v.Y-2) > 4 then
		 b.Jump = true
		end
		end
						
			b.MoveToFinished:wait()
        end
    end)
	wait(.01)
end

2 comments

0

You could try reducing the EmptyCutoff to lower the amount of filled space each voxel requires to be deemed full

0

how would i go about doing that?