I'm trying to make the npc to move to the current place it is supposed to but it doesn't.
In the output it says,Unable to cast Vector3. the error is in line 5,any help?
local torso = script.Parent.Torso.Position local base = game.Workspace.Base local human = script.Parent.Humanoid local path = game:GetService("PathfindingService"):FindPathAsync(torso,base) local points = path:GetWayPoints() for i,v in pairs(points) do local p = Instance.new("Part",workspace) p.Anchored = true p.CanCollide = false p.Size = Vector3.new("1,1,1") p.CFrame = CFrame.new(v.Position) end if path.Status == Enum.PathStatus.Success then for i,v in pairs(points) do human:MoveTo(v.Position) human.MoveToFinished:Wait() end end
This script is in the model of the npc.
In the output, it says "Unable to cast Vector3 to Instance."
You're using the base part itself and not its position.
Sometimes I make this mistake too, but thanks to the output window, I'm able to fix it quickly on my own.
Here is the code you should use...
local torso = script.Parent.Torso.Position local base = game.Workspace.Base.Position local human = script.Parent.Humanoid local path = game:GetService("PathfindingService"):CreatePath() path:ComputeAsync(torso,base) local points = path:GetWaypoints() for i,v in pairs(points) do local p = Instance.new("Part",workspace) p.Anchored = true p.CanCollide = false p.Size = Vector3.new("1,1,1") p.CFrame = CFrame.new(v.Position) end if path.Status == Enum.PathStatus.Success then for i,v in pairs(points) do human:MoveTo(v.Position) human.MoveToFinished:Wait() end end