PathFinding Script Not Working?

So, i made my own custom PathFinding script… So what it does is that it should find the nearest player to it and chase them, yet it doesn’t work? i’ve tried reading doing everything to avoid posting and doing unnecessary actions/posts… but i really cant find a solution… anyways i have no idea on what is causing this bug, what so ever…

Script
    		local NearestTarget = FindPlayer()
    		local path = PathFindingService:CreatePath()
    		
    		if NearestTarget then
    			path:ComputeAsync(ClanBossModel.HumanoidRootPart.Position, NearestTarget.HumanoidRootPart.Position)
    			print(NearestTarget.Name)
    		end
    		
    		local Waypoints = path:GetWaypoints()
    		
    		for i, waypoint in pairs(Waypoints) do
    			humanoid:WalkTo(waypoint.Position)
    			humanoid.MoveToFinished:Wait(2)
    		end

not the full script, tho… but it is where the PathFinding part is…
for some more info here is the screen shot of the bot, after joining the game and the screen shot of the output after joining the game…

Screenshots

output dev forums

boss dev forums

If you think you know the solution please consider telling me down in the comments, Thanks!

Have you checked the Path.Status yet?

2 Likes

So is the problem that it doesnt move at all

1 Like

hmm no… not really… but there are no obstacles its just plain baseplate, so i dont know why it whould error…

ahhhh, about that… i havent make it clear in the post (sorry about that) but yes, its not moving…

I’m not sure either, but it’s a good step to finding issues, I would also specify agent parameters.

Example
	local Path = PathfindingService:CreatePath({
	["AgentRadius"] = 4;
	["AgentHeight"] = 5;
	["AgentCanJump"] = false;
})
1 Like

make sure the humanoidrootpart isn’t anchor

1 Like

ah yes! about that… i havent do that ill try to when i get to my pc, thanks!

1 Like

it isnt anchored… ive checked multiple times…

One thing im confused about that tho, is that the Radius and Height… i mean is Radius X axis? and is Height in the Y axis?

Radius would be width, and Height would be how tall, or his Y Axis, most normal characters are around 4-5 studs tall and 4 studs wide.

1 Like

ohh, i get it… so meaning Radius should be X axis, anyways all clear now thanks so much!

You can find more info here about pathfinding

1 Like

okay, thanks so much!!! :smiley:

Hey there!! i added some finishing touches to my script and some things didnt work… i think its the problem with the script itself… can you please take a look at it? oh and it keeps giving me this error:
WalkTo is not a valid member of Humanoid
at this line:

humanoid:WalkTo(waypoint.Position)

this is the script:

		local NearestTarget = FindPlayer()
		
		local pathParams = {
			AgentRadius = 4,
			AgentHeight = 5,
			AgentCanJump = false --default is true
		}
		
		local path = PathFindingService:CreatePath(pathParams)
		
		if NearestTarget then
			path:ComputeAsync(ClanBossModel.HumanoidRootPart.Position, Workspace.Union.Position)
			print(NearestTarget.Name)
		end
		
		local Waypoints = path:GetWaypoints()
		
		for i, waypoint in pairs(Waypoints) do
			humanoid:WalkTo(waypoint.Position)
			humanoid.MoveToFinished:Wait(2)
		end

Note: it does print “WhatDid_HeDo” aka my username meaning that the print NearestTarget Works and that HumanoidRootPart isnt anchored

here is a pictures of it not moving:
dev forum post lol
dev forum post xD

Thanks so much!!!

It should be Humanoid:MoveTo(<Position Vector3>) for having the humanoid walk to a position.

1 Like

Or in your case

for i, waypoint in pairs(Waypoints) do
	humanoid:MoveTo(waypoint.Position)
	humanoid.MoveToFinished:Wait(2)
end
2 Likes

ohhh, yeah about that… thanks!! that works!! thanks so much!

2 Likes