Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

A better method to path find to a moving player?

Asked by 5 years ago

So I was attempting to create a path finding script for my NPC using ROBLOX's path finding service. The script is supposed to follow the player and not get stuck on walls and make sure it can follow them where ever they go.

The current script does function, its just after the player a NPC is following dies the NPC begins to track the next player but then will start going between the spot the first player died and the path in which the new player is on.

My current script

01local pathService = game:GetService("PathfindingService")
02local teams = game:GetService("Teams")
03local debris =game:GetService("Debris")
04 
05local maxDistance = 512
06 
07local undeadTeam = teams:FindFirstChild("Undead")
08local survivorsTeam = teams:FindFirstChild("Survivors")
09 
10local upper = script.Parent.UpperTorso
11local target
12 
13local humanoid = script.Parent.Humanoid
14 
15 
View all 63 lines...

if you have any questions ask away I will try and reply to them as soon as possible.

1 answer

Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
5 years ago

You can use humanoid.Running Very well with this

1CHARACTERPARENTHERE.Humanoid.Running:Connect(function()
2    --This will detect if someone is using wasd at all.
3end)
Ad

Answer this question