Aug 8, 2024
local pathFindingService = game:GetService("PathfindingService")
local human = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("Torso")
local path = pathFindingService:CreatePath()
ComputeAsync
to define start and end points.
path:ComputeAsync(torso.Position, game.Workspace.EndingPart.Position)
local waypoints = path:GetWaypoints()
for i, waypoint in ipairs(waypoints) do
human:MoveTo(waypoint.Position)
human.MoveToFinished:Wait()
end
path.Status
and PathBlocked
.if waypoint.Action == Enum.PathWaypointAction.Jump then
human:ChangeState(Enum.HumanoidStateType.Jumping)
end
local part = Instance.new("Part")
part.Size = Vector3.new(1, 1, 1)
part.Material = Enum.Material.Neon
part.Position = waypoint.Position + Vector3.new(0, 2, 0)
part.Parent = game.Workspace