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

The Pathfinding service is not working on a terrain?

Hey there, I got a basic pathfinding script for a character in my game. It worked when the character and the destination are on the baseplate, but not on a terrain. The character is not anchored.

local PathfindingService = game:GetService("PathfindingService")
 
local zombie = script.Parent
local humanoid = zombie.Humanoid
local destination = game.Workspace.dest
 
local path = PathfindingService:CreatePath()
path:ComputeAsync(zombie.HumanoidRootPart.Position, destination.Position)
humanoid:MoveTo(destination.Position)
 

Does anyone have a solution?

1 comment

0

I'm not that good at scripting but an idea is if you instead create an invisible part just on top of the terrain so that it creates the illusion that it is pathfinding on terrain... again i'm not that good at scripting but it's an idea

1 answer

Problem is that you are not actually doing pathfinding your script. You do Compute path but you don't use it, later on, you just use MoveTo to the final destination and that's not how it's supposed to be. As it's explained step by step and there is example on Roblox Dev Hub you should follow it to fix and adapt your script:

Link: https://developer.roblox.com/en-us/articles/Pathfinding

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