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.
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)
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!
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!