wait(1)
-- NPC Simple Animated R6 NPC
-- подключаем модуль поиска пути
local pathfindingService = game:GetService("PathfindingService")
-- переменные человечка, его тела и куда он пойдет
local humanoid = script.Parent.Humanoid
local body = script.Parent:FindFirstChild("HumanoidRootPart") or script.Parent:FindFirstChild("Torso")
--local player = game:GetService("Players").PlayerAdded:Wait()
--local character = player.Character
while true do
local destination = _G.position
--character.FindFirstChild("HumanoidRootPart").Position
-- создаем объект тропы
local path = pathfindingService:CreatePath()
-- вычисляем путь
path:ComputeAsync(body.Position, destination)
-- промежуточные точки перемещения
local waypoints = path:GetWaypoints()
-- перебираем все точки
for k, waypoint in pairs(waypoints) do
humanoid:MoveTo(waypoint.Position)
-- прыгаем, если это нужно
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
humanoid.MoveToFinished:Wait()
end
end