Pathfinding script not working (no error)

hello, I’m trying to make a pathfinding script. it just prints success and stuff in chat however the character doesn’t move.

here’s the script:

repeat task.wait() until game.Players:FindFirstChild("SAKDEVRBLX_alt")
task.wait(4)
--// Services

local PathfindingService = game:GetService('PathfindingService')


--// Variables

local path : Path = PathfindingService:CreatePath({
	AgentRadius = 3,
	AgentHeight = 6,
	AgentCanJump = false,
	Costs = {
		Water = 20
	}
})
local rig = script.Parent
local humanoid = script.Parent.Humanoid
local destination = Vector3.new(84, 3, -64.5)


--// Main

local success, result = pcall(function()
	path:ComputeAsync(rig.PrimaryPart.Position, destination)
end)


if (success) and (path.Status == Enum.PathStatus.Success) then
	for _, waypoint : PathWaypoint in pairs(path:GetWaypoints()) do
		humanoid:MoveTo(waypoint.Position)
		print(path.Status)
		humanoid.MoveToFinished:Wait()
		print("finished")
	end

	print('Finished path!')
else
	print(result)
	print(path.Status)
	warn('Failed to compute the path.')
end

this is what happens:

1 Like
repeat task.wait() until game.Players:FindFirstChild("SAKDEVRBLX_alt")
print("esc1")
task.wait(4)
print("esc2")
--// Services

local PathfindingService = game:GetService('PathfindingService')


--// Variables

local path : Path = PathfindingService:CreatePath({
	AgentRadius = 3,
	AgentHeight = 6,
	AgentCanJump = false,
	Costs = {
		Water = 20
	}
})
local rig = script.Parent
local humanoid = script.Parent.Humanoid
local destination = Vector3.new(84, 3, -64.5)


--// Main

local success, result = pcall(function()
	path:ComputeAsync(rig.PrimaryPart.Position, destination)
end)


if (success) and (path.Status == Enum.PathStatus.Success) then
	for _, waypoint : PathWaypoint in pairs(path:GetWaypoints()) do
		humanoid:MoveTo(waypoint.Position)
		print(path.Status)
		humanoid.MoveToFinished:Wait()
		print("finished")
	end

	print('Finished path!')
else
	print(result)
	print(path.Status)
	warn('Failed to compute the path.')
end

tell me what this prints

Are you sure the rig’s HumanoidRootPart is not anchored?

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