Pathfinding Problem

So I have this problem, this code;

Code
function PathFinding(Destination)

local path = pathfinding:CreatePath()

path:ComputeAsync(Body.Position,Destination)

local WayPoints = path:GetWaypoints()

for k, waypoint in pairs(WayPoints) do
	hum:MoveTo(waypoint.Position)
	
	
	if waypoint.Action == Enum.PathWaypointAction.Jump then
		hum:ChangeState(Enum.HumanoidStateType.Jumping)
	end
	
	hum.MoveToFinished:Wait(2) -- make this wait() maybe?
end

end

PathFinding(Dest)

use to work fine a few months ago, then I stopped coding, yesterday I started again and this code isn’t working I didn’t change anything, tried to download older versions where it worked, didn’t work there either, was there a change in Roblox Studio that does this? or is my code wrong? I tried making everything not cancollideable didn’t work, the npc doesn’t move.
Just tried printing Waypoints it printed a empty table thats probably the problem it can’t get waypoints

also tried this:

`   function PathFinding(Destination)`

    hum:MoveTo(Destination)

    end

got the same problem

1 Like

Maybe the Destination is nil or not provided?

1 Like

Nope it is definitely there. Its invisible but its there.

1 Like

Is it anchored?

What does the output say?

1 Like

the output prints {}
No its not anchored
Im pretty sure that path:GetWaypoint() is the problem but I cannot fix it.

1 Like

The desination should be anchored, it may be falling through the map.

thats also anchored, and even if it wasnt it wouldn’t fall of the map.

1 Like

Not unless cancollide is disabled.

1 Like

yes but its anchored so, that shouldn’t be the problem

you need the position of the destination.

path:ComputeAsync(Body.Position,Destination.Position)

I already have that

destination = something.something.Position

Did you make a variable for humanoid I’m not sure if you did cause I’m not seeing it

Try this the first one you didn’t assign humanoid

I already have the humanoid assigned I think the problem is that the NPC cant find a wway to go to the destination

Did you assign the path to go to a certain area or random?

I assigned it to go to a certain position

I must assume that you called the pathfinding service already

In the code did you forget to add Destination.Position?

Is the destination taller than your character? The character won’t move if the destination is higher than the character’s height.

3 Likes

I honestly can’t see the problem