Noob's Path-Finding ModuleScript v1 | Make a Path-Finding AI with 3 lines of Code

In May, I made a Path-Finding Module Script and made a Youtube Video showcasing it. Now I will share it to the Dev-Forum

This is a Module-Script used to make Path-Finding AI’s really quickly. This is the First Version of the Module-Script. So there isn’t really that much, and will get more updates.

How to Use

This is a video. I’ve made in May. Teaching how to use it. If you want to learn the API Quickly. I would recommend watching this.

If you want an API now here it is:

API

  • Note: Require the Module before using it
PFS:New()
  • Creates a New Path-Finder (Recommended)
  • Returns the Path-Finder
local PF = PFS:New()
PF:CreatePath()
Parameters
  • Start Position
  • End Position
  • Humanoid

Note that the AI will start to walk on the path you created when you make that line of code.

Other Information

  • The Module-Script is Open-Source so you can see what is inside of the Module-Script

This is all that Noob’s Path-Finding Module Script can do. If you want more features. Please reply to this Post. I will make some updates. When I get feedback in the Replies. Thank you for using my Module-Script :slight_smile:

5 Likes

This post does not convey much information. What makes this better than the normal PathfindingService, which also only requires three lines?

Yes which bascially is for making a Simple-AI go to 1 Path

Example

local PFS = require(ModulePath)
local PF = PFS:New()
PF:CreatePath(startPositionPath,endPositionPath,humanoidPath)

That answer doesn’t make sense, it doesn’t respond to his question.

His question rephrased:
“Why should I use this module instead of the default Roblox Pathfinding?”

The default pathfinding takes the same amount of code lines, this really feels like a mirror (porting the Pathfinding service).

What makes this module special? What problems does this solve which sets this module apart from the Pathfinding service?

Please don’t answer with “yes”

1 Like

Ok I read your reply wrong. Here is what I should say.

I think you should use this because making a Path-Finding AI without this Module is longer than what you have to do simply.

This is what a Path-Finding AI would be by just using the PathFindingService

local PFS = game:GetSerice("PathFindingService")
local path = PFS:CreatePath()
path:ComputeAsync(startPosition,endPosition)
local waypoints = path:GetWaypoints()
	
for _,waypoint in pairs(waypoints) do
	if waypoint.Action == Enum.PathWaypointAction.Jump then
		humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
	end
		
	humanoid:MoveTo(waypoint.Position)
	humanoid.MoveToFinished:Wait()
		
end

But, in my Module. You just need to put 3 Lines of Code.

2 Likes

This is quite convenient imo. Cool, my dude.

Glad to hear that :slight_smile:

This module is pretty good, but what’s the point of PathFinding:New()? All it does is return a read-only version of the module. :thinking:

function PathFinding:New()
	self.__index = self 
	
	return setmetatable({},self)
end

Not only that, but you should also mention that it only works for R6 humanoids.

Now that I think of it. The New Function is pretty useless. I will maybe try to make it a bit more useful or will just remove it

Is it possible to make it repeat? So that the npc goes back to their starting position?

There is not quite function yet for that, but I’ll try to make an update for that soon.

1 Like