{"id":129,"date":"2025-01-06T16:06:22","date_gmt":"2025-01-06T21:06:22","guid":{"rendered":"https:\/\/kushaltimsina.com\/blog\/?p=129"},"modified":"2025-01-20T09:32:15","modified_gmt":"2025-01-20T14:32:15","slug":"how-to-script-npc-pathfinding-on-roblox","status":"publish","type":"post","link":"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/","title":{"rendered":"How to Script NPC Pathfinding on Roblox"},"content":{"rendered":"\n<p>If you want to script NPC Pathfinding on Roblox, it&#8217;s is actually very simple. In this blog, you&#8217;ll learn how to script NPC Pathfinding on Roblox in an easy way.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\"><strong>What is NPC Pathfinding?<\/strong><\/h2>\n\n\n\n<p>NPC Pathfinding is when you have an NPC, and you&#8217;d like it to travel to a destination, avoiding objects along the way.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\"><strong>How to Make NPCs Walk in Roblox<\/strong><\/h2>\n\n\n\n<p>To make NPCs walk to a certain destination, you can use the Humanoid:MoveTo function.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"579\" src=\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-2-1024x579.png\" alt=\"A Noob and a SpawnLocation, preparing for NPC Pathfinding.\" class=\"wp-image-130\" srcset=\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-2-1024x579.png 1024w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-2-300x170.png 300w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-2-768x434.png 768w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-2.png 1404w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Let&#8217;s say that we want the Noob to travel to the SpawnLocation. How would we script this?<\/p>\n\n\n\n<p>Well, it&#8217;s easy enough: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>local noob = workspace.Noob \nnoob.Humanoid:MoveTo(workspace.SpawnLocation.Position)<\/code><\/pre>\n\n\n\n<p>In here, all we&#8217;re saying is &#8220;Let the Noob walk straight to the spawn location&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"612\" height=\"488\" src=\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-3.png\" alt=\"A Noob that has reached the SpawnLocation using the MoveTo function.\" class=\"wp-image-131\" srcset=\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-3.png 612w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-3-300x239.png 300w\" sizes=\"auto, (max-width: 612px) 100vw, 612px\" \/><\/figure>\n\n\n\n<p>And it manages to walk straight to the SpawnLocation. Just as we wanted.<\/p>\n\n\n\n<p>But what if there&#8217;s an object in the way?<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"597\" src=\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-4-1024x597.png\" alt=\"A Noob that has to reach the SpawnLocation, but a red brick is in the way.\" class=\"wp-image-132\" srcset=\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-4-1024x597.png 1024w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-4-300x175.png 300w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-4-768x448.png 768w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-4-1536x896.png 1536w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-4.png 1578w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>What do you think will happen? <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"168\" height=\"288\" src=\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-5.png\" alt=\"The Noob has collided with the red brick.\" class=\"wp-image-133\"\/><\/figure>\n\n\n\n<p>Well, the Noob gets stuck, because, well, there&#8217;s a giant red block in the way. In particular, when you use the  <code>MoveTo<\/code> function, Roblox just makes the Noob travel straight to its destination.<\/p>\n\n\n\n<p>But we can do better.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\"><strong>How to Make NPCs Avoid Obstacles in Roblox using PathfindingService<\/strong> <\/h2>\n\n\n\n<p>To make NPCs avoid objects in Roblox, you&#8217;ll want to use something called PathfindingService.<\/p>\n\n\n\n<p>PathfindingService has functions that do a whole bunch of calculations to get your NPC to a destination, while intelligently avoiding obstacles.<\/p>\n\n\n\n<p>Earlier, when the NPC tried to go to the SpawnLocation, it got stuck! But, with PathfindingService, we can get past this.<\/p>\n\n\n\n<p>We have to start by telling the PathfindingService that you want to create a new path.<\/p>\n\n\n\n<pre class=\"wp-block-code has-contrast-color has-text-color has-link-color has-small-font-size wp-elements-2d040723fa6e49bb4fc0246e3d5d4e62\"><code>local PathfindingService = game:GetService(\"PathfindingService\")\n\nlocal path = PathfindingService:CreatePath()<\/code><\/pre>\n\n\n\n<p>Here, we&#8217;ve told PathfindingService that we intend on creating a new path, and stored it in the variable &#8220;path.&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-code has-contrast-color has-base-background-color has-text-color has-background has-link-color has-small-font-size wp-elements-cdb27084de739ac84f67ba7eae5f5155\"><code>local success, errorMessage = pcall(function()\n\t\t    path:ComputeAsync(workspace.Noob.HumanoidRootPart.Position, workspace.SpawnLocation.Position)\n\nend)<\/code><\/pre>\n\n\n\n<p>All NPCs have something called a HumanoidRootPart, which is an invisible block in their torso. <\/p>\n\n\n\n<p>Here, we&#8217;ve told Roblox that we want that path to compute a path (using <code>ComputeAsync<\/code> from the position of the Noob&#8217;s HumanoidRootPart to the position of the SpawnLocation.<\/p>\n\n\n\n<p>Remember that now, since there&#8217;s an obstacle in the way, the Noob can&#8217;t just walk straight to the SpawnLocation. It has to take a detour.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"748\" src=\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6-1024x748.png\" alt=\"Blue blocks show a possible path that the Noob can take for NPC Pathfinding.\" class=\"wp-image-134\" srcset=\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6-1024x748.png 1024w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6-300x219.png 300w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6-768x561.png 768w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6.png 1526w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In the illustration above, we can see that in order to avoid the red block, the Noob has to sequentially walk to the various blue blocks.<\/p>\n\n\n\n<p>This means that we have to call <code>:WalkTo<\/code>, not straight into the SpawnLocation, but straight to the position of every blue block. In other words, the Noob has to :WalkTo the first blue block&#8217;s position, then the second blue block&#8217;s position, etc.<\/p>\n\n\n\n<p>Note that this is a list of positions.<\/p>\n\n\n\n<p>Remember the <code>ComputeAsync<\/code>? That line of code basically told Roblox to run an algorithm to figure out a list of positions to go from it&#8217;s current position to the SpawnLocation, while avoiding the red block.<\/p>\n\n\n\n<p>And now, we need Roblox to actually give us that list of positions (the positions of the blue blocks).<\/p>\n\n\n\n<pre class=\"wp-block-code has-contrast-color has-text-color has-link-color wp-elements-468b7bef50e8bd95320a97f93a4583f5\"><code>if success and path.Status == Enum.PathStatus.Success then\n\t-- Get the path waypoints\n\twaypoints = path:GetWaypoints()\nend<\/code><\/pre>\n\n\n\n<p>So here, we check to make sure that the path was successful, and we get that list of positions by using <code>path:GetWaypoints()<\/code>. <\/p>\n\n\n\n<p>So now, we have a list of positions that the Noob has to walk to, in order to avoid that red block (as well as any other obstacles in the way).<\/p>\n\n\n\n<p>And we just have to cycle through every waypoint and make our Noob move to that position.<\/p>\n\n\n\n<pre class=\"wp-block-code has-contrast-color has-text-color has-link-color has-small-font-size wp-elements-2b224984dec8dd978d49caa8825b7c87\"><code>local PathfindingService = game:GetService(\"PathfindingService\")\n\nlocal path = PathfindingService:CreatePath()\n\nlocal success, errorMessage = pcall(function()\n\t\t    path:ComputeAsync(workspace.Noob.HumanoidRootPart.Position, workspace.SpawnLocation.Position)\n\nend)\n\nif success and path.Status == Enum.PathStatus.Success then\n    waypoints = path:GetWaypoints()\n    \n    for i, waypoint in next, waypoints do\n        workspace.Noob.Humanoid:MoveTo(waypoint.Position)\n        workspace.Noob.Humanoid.MoveToFinished:Wait()\n    end\n      \nend<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"578\" src=\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-7-1024x578.png\" alt=\"The Noob has successfully used NPC pathfinding to reach the spawn location.\" class=\"wp-image-135\" srcset=\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-7-1024x578.png 1024w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-7-300x169.png 300w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-7-768x433.png 768w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-7.png 1202w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>And there you have it! The Noob has successfully gotten around the red block.<\/p>\n\n\n\n<p>Thank you for reading. <\/p>\n\n\n\n<p>If you like my style of explanation and you learned something, make sure to check out my book, the <a href=\"http:\/\/kushaltimsina.com\/book\">Beginner&#8217;s Guide to Roblox Scripting.<\/a> The book will teach you Roblox Scripting in a way that is easy to follow.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"kushaltimsina.com\/book\"><img loading=\"lazy\" decoding=\"async\" width=\"510\" height=\"680\" src=\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-1.png\" alt=\"The Beginner's Guide to Roblox Scripting Book.\" class=\"wp-image-126\" srcset=\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-1.png 510w, https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-1-225x300.png 225w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/figure>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"http:\/\/kushaltimsina.com\/book\">Get the book<\/a><\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to script NPC Pathfinding on Roblox, it&#8217;s is actually very simple. In this blog, you&#8217;ll learn how to script NPC Pathfinding on Roblox in an easy way. What is NPC Pathfinding? NPC Pathfinding is when you have an NPC, and you&#8217;d like it to travel to a destination, avoiding objects along the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":134,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[7,14],"class_list":["post-129","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-roblox-scripting-tutorials","tag-game-development","tag-roblox-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Script NPC Pathfinding on Roblox - Kushal Writes<\/title>\n<meta name=\"description\" content=\"NPC Pathfinding is when you have an NPC, and you&#039;d like it to travel to a destination, avoiding objects along the way. In this article, we&#039;ll learn how to make a Guest walk to a SpawnLocation.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Script NPC Pathfinding on Roblox - Kushal Writes\" \/>\n<meta property=\"og:description\" content=\"NPC Pathfinding is when you have an NPC, and you&#039;d like it to travel to a destination, avoiding objects along the way. In this article, we&#039;ll learn how to make a Guest walk to a SpawnLocation.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/\" \/>\n<meta property=\"og:site_name\" content=\"Kushal Writes\" \/>\n<meta property=\"article:published_time\" content=\"2025-01-06T21:06:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-20T14:32:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1526\" \/>\n\t<meta property=\"og:image:height\" content=\"1114\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"kushal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kushal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/\"},\"author\":{\"name\":\"kushal\",\"@id\":\"https:\/\/kushaltimsina.com\/blog\/#\/schema\/person\/9ae64ce30587c804d89b1eef21ba5d2f\"},\"headline\":\"How to Script NPC Pathfinding on Roblox\",\"datePublished\":\"2025-01-06T21:06:22+00:00\",\"dateModified\":\"2025-01-20T14:32:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/\"},\"wordCount\":629,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/kushaltimsina.com\/blog\/#\/schema\/person\/9ae64ce30587c804d89b1eef21ba5d2f\"},\"image\":{\"@id\":\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6.png\",\"keywords\":[\"game development\",\"roblox scripting\"],\"articleSection\":[\"Roblox Scripting Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/\",\"url\":\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/\",\"name\":\"How to Script NPC Pathfinding on Roblox - Kushal Writes\",\"isPartOf\":{\"@id\":\"https:\/\/kushaltimsina.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6.png\",\"datePublished\":\"2025-01-06T21:06:22+00:00\",\"dateModified\":\"2025-01-20T14:32:15+00:00\",\"description\":\"NPC Pathfinding is when you have an NPC, and you'd like it to travel to a destination, avoiding objects along the way. In this article, we'll learn how to make a Guest walk to a SpawnLocation.\",\"breadcrumb\":{\"@id\":\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#primaryimage\",\"url\":\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6.png\",\"contentUrl\":\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6.png\",\"width\":1526,\"height\":1114},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/kushaltimsina.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Script NPC Pathfinding on Roblox\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/kushaltimsina.com\/blog\/#website\",\"url\":\"https:\/\/kushaltimsina.com\/blog\/\",\"name\":\"Kushal Timsina\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/kushaltimsina.com\/blog\/#\/schema\/person\/9ae64ce30587c804d89b1eef21ba5d2f\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/kushaltimsina.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/kushaltimsina.com\/blog\/#\/schema\/person\/9ae64ce30587c804d89b1eef21ba5d2f\",\"name\":\"kushal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kushaltimsina.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2024\/11\/tempImage75F1Sw-edited.jpg\",\"contentUrl\":\"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2024\/11\/tempImage75F1Sw-edited.jpg\",\"width\":1274,\"height\":849,\"caption\":\"kushal\"},\"logo\":{\"@id\":\"https:\/\/kushaltimsina.com\/blog\/#\/schema\/person\/image\/\"},\"description\":\"Kushal Timsina has been developing Roblox games since 2016, played 40,000,000+ times, teaches Roblox scripting on YouTube to 1,000,000+ views, and is the author of the Beginner's Guide to Roblox Scripting book.\",\"sameAs\":[\"https:\/\/kushaltimsina.com\/blog\"],\"url\":\"https:\/\/kushaltimsina.com\/blog\/author\/kushal\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Script NPC Pathfinding on Roblox - Kushal Writes","description":"NPC Pathfinding is when you have an NPC, and you'd like it to travel to a destination, avoiding objects along the way. In this article, we'll learn how to make a Guest walk to a SpawnLocation.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/","og_locale":"en_US","og_type":"article","og_title":"How to Script NPC Pathfinding on Roblox - Kushal Writes","og_description":"NPC Pathfinding is when you have an NPC, and you'd like it to travel to a destination, avoiding objects along the way. In this article, we'll learn how to make a Guest walk to a SpawnLocation.","og_url":"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/","og_site_name":"Kushal Writes","article_published_time":"2025-01-06T21:06:22+00:00","article_modified_time":"2025-01-20T14:32:15+00:00","og_image":[{"width":1526,"height":1114,"url":"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6.png","type":"image\/png"}],"author":"kushal","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kushal","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#article","isPartOf":{"@id":"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/"},"author":{"name":"kushal","@id":"https:\/\/kushaltimsina.com\/blog\/#\/schema\/person\/9ae64ce30587c804d89b1eef21ba5d2f"},"headline":"How to Script NPC Pathfinding on Roblox","datePublished":"2025-01-06T21:06:22+00:00","dateModified":"2025-01-20T14:32:15+00:00","mainEntityOfPage":{"@id":"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/"},"wordCount":629,"commentCount":0,"publisher":{"@id":"https:\/\/kushaltimsina.com\/blog\/#\/schema\/person\/9ae64ce30587c804d89b1eef21ba5d2f"},"image":{"@id":"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#primaryimage"},"thumbnailUrl":"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6.png","keywords":["game development","roblox scripting"],"articleSection":["Roblox Scripting Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/","url":"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/","name":"How to Script NPC Pathfinding on Roblox - Kushal Writes","isPartOf":{"@id":"https:\/\/kushaltimsina.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#primaryimage"},"image":{"@id":"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#primaryimage"},"thumbnailUrl":"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6.png","datePublished":"2025-01-06T21:06:22+00:00","dateModified":"2025-01-20T14:32:15+00:00","description":"NPC Pathfinding is when you have an NPC, and you'd like it to travel to a destination, avoiding objects along the way. In this article, we'll learn how to make a Guest walk to a SpawnLocation.","breadcrumb":{"@id":"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#primaryimage","url":"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6.png","contentUrl":"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2025\/01\/image-6.png","width":1526,"height":1114},{"@type":"BreadcrumbList","@id":"https:\/\/kushaltimsina.com\/blog\/2025\/01\/06\/how-to-script-npc-pathfinding-on-roblox\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kushaltimsina.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Script NPC Pathfinding on Roblox"}]},{"@type":"WebSite","@id":"https:\/\/kushaltimsina.com\/blog\/#website","url":"https:\/\/kushaltimsina.com\/blog\/","name":"Kushal Timsina","description":"","publisher":{"@id":"https:\/\/kushaltimsina.com\/blog\/#\/schema\/person\/9ae64ce30587c804d89b1eef21ba5d2f"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kushaltimsina.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/kushaltimsina.com\/blog\/#\/schema\/person\/9ae64ce30587c804d89b1eef21ba5d2f","name":"kushal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kushaltimsina.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2024\/11\/tempImage75F1Sw-edited.jpg","contentUrl":"https:\/\/kushaltimsina.com\/blog\/wp-content\/uploads\/2024\/11\/tempImage75F1Sw-edited.jpg","width":1274,"height":849,"caption":"kushal"},"logo":{"@id":"https:\/\/kushaltimsina.com\/blog\/#\/schema\/person\/image\/"},"description":"Kushal Timsina has been developing Roblox games since 2016, played 40,000,000+ times, teaches Roblox scripting on YouTube to 1,000,000+ views, and is the author of the Beginner's Guide to Roblox Scripting book.","sameAs":["https:\/\/kushaltimsina.com\/blog"],"url":"https:\/\/kushaltimsina.com\/blog\/author\/kushal\/"}]}},"_links":{"self":[{"href":"https:\/\/kushaltimsina.com\/blog\/wp-json\/wp\/v2\/posts\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kushaltimsina.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kushaltimsina.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kushaltimsina.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kushaltimsina.com\/blog\/wp-json\/wp\/v2\/comments?post=129"}],"version-history":[{"count":1,"href":"https:\/\/kushaltimsina.com\/blog\/wp-json\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":136,"href":"https:\/\/kushaltimsina.com\/blog\/wp-json\/wp\/v2\/posts\/129\/revisions\/136"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kushaltimsina.com\/blog\/wp-json\/wp\/v2\/media\/134"}],"wp:attachment":[{"href":"https:\/\/kushaltimsina.com\/blog\/wp-json\/wp\/v2\/media?parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kushaltimsina.com\/blog\/wp-json\/wp\/v2\/categories?post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kushaltimsina.com\/blog\/wp-json\/wp\/v2\/tags?post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}