Pathfinding Doesnt Work

MY PATHFINDING DOESNT WORK

  • Theres no errors but it doesnt walk to points
  • he just stands there, menecingly
  • if you can help then help plz
local wps = script.Parent.Parent.Parent.WayPointsNormal
local wpIdx = 1
local char = script.Parent
local hum = char:WaitForChild("Humanoid")

local rad
local rad2
while wait() do
	
	rad = math.random(1, #wps:GetChildren())
	
	rad2 = math.random(5, 10)
	
end

local path = game.PathfindingService:CreatePath()
path:ComputeAsync(script.Parent.HumanoidRootPart.Position, script.Parent.Parent.Parent.WayPointsNormal:FindFirstChild(rad))

for _, waypoint in pairs(path:GetWaypoints()) do
	
	script.Parent.Humanoid:MoveTo(waypoint.Position)
	
	script.Parent.Humanoid.MoveToFinished:Wait()
	
	wait(rad2)
	
end

you have a while wait loop at the top which blocks the code further down
i suggest putting it at the very bottom

1 Like