Trouble with pathfinding vector3 parameter

I have a working pathfinding script that moves an NPC from point A to point B (Vector3.new(x,y,z)). However, the script only works, as in the path only computes when the destination is a vector 3 position. The problem is that I want to be able to use a part’s position as the destination, and this breaks the script. The reason for this is that I want to store more information at each destination, such as int values as children of each part that list the next possible destinations. If anyone knows a better way to store this information/fix the position problem, that would be greatly appreciated.

After some debugging, I have found that this solution works:

local pos = game.Workspace.endPoint.CFrame.Position
local TEST_DESTINATION = Vector3.new(pos.X, 0, pos.Z)

Using the X and Z values of the part, I am able to get the part’s position, but only if I leave one of the values as an integer (in this case Y) in a vector3 instance. It does not work with Vector3.new(pos.X, pos.Y, pos.Z). I find this kid of odd but it probably points to the issue here.

I forgot to mention this but followPath(pos) doesn’t work

1 Like

why dont you use roblox’s Pathfinding Service?

1 Like

I am using the pathfinding service. My followPath(destination) function uses pathfinding service to move an NPC from point a to point b.

path:ComputeAsync(character.PrimaryPart.Position, destination)

can you post your code for me to see

1 Like

how many waypoints are there in between your NPC and endpoint? and is your error that it stops moving?

1 Like

Not sure how many waypoints. The error is that when I pass in the position of a part in my followPath function, it just doesn’t move. But, when I pass in a vector3 position or Vector3.new(pos.x, 0, pos.y) it works (at least 1 int). The latter option seems to be a fine solution, albeit less convenient.

1 Like