Problem with pathfindingservice

I have now got a object that follows a trail using the pathfindingservice however once it has reached its end goal it just starts sliding off. Does anybody know why

Link of example:
https://gyazo.com/4eaa11260685c3f0fe2c2c21fe62e038

Code:

local PathFindingService = game:GetService("PathfindingService")
wait(3)
local Humanoid = script.Parent:WaitForChild("Humanoid")
local Root = script.Parent:WaitForChild("HumanoidRootPart")
local path = PathFindingService:CreatePath()
Root:SetNetworkOwner(nil)

path:ComputeAsync(Root.Position,workspace.Obj.Position)

local waypoints = path:GetWaypoints()

for _,v in pairs(waypoints) do
	local part = Instance.new("Part")
	part.Shape = "Ball"
	part.Material = "Neon"
	part.Position = v.Position
	part.Size = Vector3.new(0.6,0.6,0.6)
	part.Anchored = true
	part.CanCollide = false
	part.Parent = workspace
	Humanoid:MoveTo(v.Position)
	Humanoid.MoveToFinished:Wait()
	print("moved")
end
print("finished")
1 Like

Did you anchor the part? It may be drifting from other causes, check for scripts that affect it.

1 Like

i think the problem is due to the humanoidrootpart placement, however im not sure where to place it

4

that is the placement right now which is causing it to move on its own, even if i disable the pathfinding script

Perhaps it is, have you tried anchoring it?

anchoring it stops the moving on its own, however it also disables the pathfinding script all together

Perhaps you could un-anchor it when you want it to move?

eg. anchoring the part when you’ve reached the end, and unanchoring the part when moving

that might work but then i can’t set the network owner, script returns an error disallowing anchored parts to be set a network owner

Maybe try putting a BodyPosition in the part when it stops?

tried that but as there is a velocity on the humanoidrootpart adding the bodyposition to keep it in place causes shaking on the entire model

Try removing the velocity temporarily?

that’s what im trying to do i cant figure out on how to remove this constant velocity that is being forced upon every part in this model, due to the humanoidrootpart, if i change the positioning to where the model doesn’t move on its own it will no longer follow the pathfinding

Do you have any other scripts that are affecting the part?

no the only one affecting the part is the pathfindingscript that i pasted above

Try turning off all the collisions of other parts except the part?

Thanks that worked i turned off collisions for all the humanoid parts expect the humanoidrootpart now it works :slight_smile:

1 Like