NPC which walkes between Paths, but gets stuck when a part is between the paths

Hi Roblox Community,

So I’m trying to make a NPC who walks randomly between paths, this is working fine, but when something is between this path, the NPC just walks in it and stops. This im my script:

wait()
local NpcHumanoid = script.Parent
local WayPoints = workspace.WayPoints:GetChildren()
local PathService = game:GetService("PathfindingService")

function patrol()
	local randomwaypoint = math.random(1, #WayPoints)
	local chosenwaypoint = WayPoints[randomwaypoint]
	
	NpcHumanoid:MoveTo(chosenwaypoint.Position)
	NpcHumanoid.MoveToFinished:Wait()
end
while (true) do
	wait()
	patrol()
end

I hope someone can help me
~ Maini

Can someone answer please? I rerally need a answer

Nevermind, I made it myself, but thanks for answering! :laughing:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.