Check if a SimplePath path finished

I’m using the SimplePath module which is really cool, and I’m using it for my AI.
When the NPC doesnt see any players it will wander around the map.

coroutine.wrap(function()
	while wait() do
		if WanderingVal.Value == true then
			local WAYS = workspace.FigureWaypoints:GetChildren()
			local RANDOMWAY = WAYS[math.random(1,#WAYS)]
			
			NPC_Path:Run(RANDOMWAY)
		end
	end
end)()

Everything works, but the NPC just cant choose the right path. He will go left right left right.
Is there a Path finished function for this module?

This is happening because the loop keeps playing sending a new random way over and over again. An easy fix would be to check if WanderingVal.Value is true and then running NPC_Path:Run(RANDOMWAY) just once.

Here’s a good way to do it using the GetPropertyChangedSignal method.

Like this:

WanderingVal:GetPropertyChangedSignal("Value"):Connect(function()
	if WanderingVal.Value == true then
		local WAYS = workspace.FigureWaypoints:GetChildren()
		local RANDOMWAY = WAYS[math.random(1,#WAYS)]
		
		NPC_Path:Run(RANDOMWAY)
	end
end)

lmk if it works!

didnt work, he only moved to the path ONCE, i want him to wander always when a player is not in range

yeah theres probably no movetofinished function whatsoever

Since it’s a custom module, and there isn’t an event to detect when it is finished, you should look into the source code and change it or even add your own MoveToFinished function!

Yeah ill try to make one myself

Wait! I just looked up the SimplePath module and looked into their GitHub documentation.

Turns out they DO have a Reached event :slight_smile:

The documentation is also very helpful and all methods/events are there so I think it could really help you out! Also, please do more research on modules you use before posting about them!

yeah I know Im kinda stupid sometimes XD thanks for the help

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.