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

Why Isn't the pathfinding script for a zombie not working?

Asked by 3 years ago

So I made a script that makes a zombie follow the player, but also have pathfinding (Meaning It can find the player In mazes,behind walls,etc. but It appears to not follow the player:

01local NPC = script.Parent
02local PathfindingService = game:GetService('PathfindingService')
03local Players = game:GetService("Players")
04local player
05 
06game.Players.PlayerAdded:Connect(function(client)
07    player = client
08end)
09 
10repeat wait() until player ~= nil
11 
12local path = PathfindingService:CreatePath()
13 
14path:ComputeAsync(NPC.Torso.Position, player.Character.PrimaryPart.Position)
15 
View all 32 lines...

1 answer

Log in to vote
1
Answered by
NEILASc 84
3 years ago

you dont use the player.primarypart.position on the move to. you have to move to the ball because that makes the pathfinding well work

01local NPC = script.Parent
02local PathfindingService = game:GetService('PathfindingService')
03local Players = game:GetService("Players")
04local player
05 
06game.Players.PlayerAdded:Connect(function(client)
07    player = client
08end)
09 
10repeat wait() until player ~= nil
11 
12local path = PathfindingService:CreatePath()
13 
14path:ComputeAsync(NPC.Torso.Position, player.Character.PrimaryPart.Position)
15 
View all 32 lines...
Ad

Answer this question