So i’m trying to make an NPC walk around to random parts of the world. And sometimes it might fail so I tried to make it return to a part if the path is not successful and when i do the statment i get ‘Postion’ is not a valid member of PathWaypoint
Here is my code Help would be appreciated
while true do
local ReturnPart = workspace.Lobby.Aquariam.ReturnPart
local Character = script.Parent
local HRP = Character.HumanoidRootPart
local Humanoid = Character.Humanoid
local PathFindingService = game:GetService("PathfindingService")
local Path = PathFindingService:CreatePath()
Path:ComputeAsync(HRP.Position, HRP.Position + Vector3.new(math.random(1, 100), 0, math.random(1, 100)))
if Path.Status == Enum.PathStatus.Success then
local WayPoints = Path:GetWaypoints()
for i,v in pairs(WayPoints) do
Humanoid:MoveTo(v.Position)
Humanoid.MoveToFinished:Wait()
if v.Action == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
end
end
else
Path:ComputeAsync(HRP.Position,ReturnPart.Position)
local Waypoints = Path:GetWaypoints()
for i,v in pairs(Waypoints) do
print(v)
Humanoid:MoveTo(v.Postion)
Humanoid.MoveToFinished:Wait()
if v.Action == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
end
end
end
wait(1.5)
end