Path finding script help

Hellooo I’m following a scripting tutorial on path finding and my script isn’t working for some reason. Whenever I run it the character stays still and it’s supposed to go to a maroon part. Here is the code and tell me if something is wrong with it.

local PathfindingService = game:GetService("PathfindingService")
local maroon = game.Workspace.maroon
local human = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("Torso")

local path = PathfindingService:CreatePath()
path:ComputeAsync(torso.positon, maroon.Position)
local waypoints = path:GetWaypoints()

for i, waypoint in pairs(waypoints) do 
	human:MoveTo(waypoint.Position)
	human.MoveToFinished:Wait(2)
end

human:MoveTo(maroon.Position)
)

You misspelt position on the torso here.

1 Like

You’re right! :joy: I ran the game but it still didn’t work though

Hmmm. Are there any errors? Is the humanoid set up properly with joints and is it unanchored?

It was unanchored and I fixed that, still doesn’t work and there are no errors in the output. I believe the joins are set up but I did use a plugin

Did you check if there is a Humanoid and a Torso?

If there wasn’t the “WaitForChild” would infinitely yield.

This script might work: (Also the script works good, the reason why it won’t move is below)

Also, never keep torso, as r6 and r15 have different avatar models

local PathfindingService = game:GetService("PathfindingService")
local maroon = game.Workspace:WaitForChild("maroon")
local startingposition = maroon.HumanoidRootPart.Position
local human = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("HumanoidRootPart")

local path = PathfindingService:CreatePath()
path:ComputeAsync(torso.Position, maroon.Position)
local waypoints = path:GetWaypoints()

for i, waypoint in pairs(waypoints) do 
	human:MoveTo(waypoint.Position)
	human.MoveToFinished:Wait(2)
end

human:MoveTo(startingposition)

Sorry for replying so late! :sweat_smile: I just tried it and it didn’t work but even if it did I have a two questions. Is the humanoid root part the torso? Why would the humanoid move to the starting position ?

Not sure but you can keep the position as something else also you cannot keep cframe in path finding compute a sync, you can keep vector 3 only