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)
)
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! 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 ?