Pathfinding script not moving character to the part

Hi I am learning to script and I was learning from this tutorial pathfinding script but it doesn’t move the character to the ending part as it is supposed to. Can anyone help me with this?

local PathfindingService = game:GetService("PathfindingService") 

local human = script.Parent:WaitForChild("Humanoid") 
local torso = script.Parent:WaitForChild("Torso") 

local Path = PathfindingService:CreatePath() 
Path:ComputeAsync(torso.Position , game.Workspace.endingPart.Position) 
local waypoints = Path:GetWaypoints() 


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


human:MoveTo(game.Workspace.endingPart.Position) 

Instead i get this error

15:46:21.890 - Workspace.heroguy1134.Pathfinding:13: Expected ‘(’, ‘{’ or when parsing function call, got ‘:’

Hmmmmm.

human.MoveToFinished:Wait(2)

it says this now
15:55:55.221 - Moveto is not a valid member of Humanoid

Remove this line:

human:MoveTo(game.Workspace.endingPart.Position)

Remember scripting is case sensitive.

MoveTo, not Moveto.

local PathfindingService = game:GetService("PathfindingService") 

local human = script.Parent:WaitForChild("Humanoid") 
local torso = script.Parent:WaitForChild("Torso") 

local Path = PathfindingService:CreatePath() 
Path:ComputeAsync(torso.Position , game.Workspace.endingPart.Position) 
local waypoints = Path:GetWaypoints() 


for i , waypoint in pairs(waypoints) do 
	human:MoveTo(waypoint.Position)
	local targetReached = false
	connection = human.MoveToFinished:Connect(function(reached)
		targetReached = true
		connection:Disconnect()
		connection = nil
	end)
	
	local StartTick = tick()
	local Timeout = 2
	repeat
		wait()
	until
		targetReached == true or (tick() - StartTick) >= Timeout
end 


human:MoveTo(game.Workspace.endingPart.Position) 
1 Like

hey the script aint working now

errors?

studio file?


oh sorry it works actually I was testing with my old script lol