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

Can you proof read this pathfinding algorithm?

So I made two Humanoid people. One of them is named AI and the other Test. At first when I ran the script it would make the character move to to the Test's direction, but just in a straight line. Which means I had to make a loop right? So I did, and now it doesn't move at all!Plus I have no output... Please help guys.

The Script

local a = game.Workspace:FindFirstChild("Test")
local b = script.Parent


if a then 
 
local path = game:GetService("PathfindingService")

while  wait(4) do
local route = path:ComputeRawPathAsync(b.Torso.Position, a.Torso.Position, 200)
	if route.Status == "Enum.PathStatus.Success" then
	b.Humanoid:Move(a.Torso.Position)

	
	end

	end
end

10 comments

4

my eyes

0

Lol drew. But yes, putting that into Lua format would be a lot less strenuous to observe.

0

ohh

0

Wait how?

0

Edited your question for you. Enjoy.

0

Just from taking a short look i can tell you're going to have a problem with that if statement and string. Comparing route.Status to a string will return false because you're not comparing it with the actual Enum value.

0

But that's about all i'm useful for here. I haven't looked at the PathFinding API yet.

0

Well it at least got it moving now that I fixed it and thank you Ayonjun!

0

Come on please help someone?

0

I can look into PathFinding and help you. But i'm going to bed now.

1 answer

local a = game.Workspace:WaitForChild("Test")
local b = script.Parent
local path = game:GetService("PathfindingService")
-- I'm not sure why you're using a loop. It usually only has to run ONCE to get to the point. Or else major lag would occur.
local route = path:ComputeRawPathAsync(b.Torso.Position, a.Torso.Position, 200)
   if route.Status == Enum.PathStatus.Success then
   	 b.Humanoid:WalkToPoint(a.Torso.Position) -- Changed to WalkToPoint because Move isn't a thing?
end

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