Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does my Path-finding script not return any errors but it won't make the dummy move?

I created a basic Path-finding script because it is my first time dealing with it. I created this as a base for testing. No errors are returned and the prints work fine. I inserted my avatar through the Load Character Plugin for the dummy, meaning that only HRP is anchored.

local PathFindingService = game:GetService("PathfindingService")
local Bone = script.Parent.HumanoidRootPart
local Human = script.Parent.Humanoid

local function GrabTarget()
	local playertable = game.Players:GetChildren()
	local target
	local targetmag
	for i, player in pairs(playertable) do
		local char = player.Character or player.CharacterAdded:Wait()
		local rootpart = char.HumanoidRootPart
		local mag = (rootpart.Position - Bone.Position).Magnitude
		print(mag)
		if target == nil or mag < targetmag then
			target = player
			targetmag = mag
		end
	end
	return target
end

wait(10)

local path = PathFindingService:CreatePath()
local togoto = GrabTarget()
print(togoto.Character.HumanoidRootPart.Position)
path:ComputeAsync(Bone.Position, togoto.Character.HumanoidRootPart.Position)

for i,waypoint in pairs(path:GetWaypoints()) do
	Human:MoveTo(waypoint.Position)
	Human.MoveToFinished:Wait()
end

2 comments

0

unachor the hrp

0

Thanks!

2 answers

✓ Accepted answer

Well since that was the answer you can mark this as solved

VerdommeMan was correct. The HRP shouldn't be anchored.

This discussion is preserved as it was. New answers, comments, and votes are closed.