I wanted to script a weapon that summons zombies that follow the owner (The person who summoned them) and whoever comes near the zombies following the owner, It will target the said person and stop If the person died, I was told to use GetPlayerFromCharacter() to see If the zombies are touching there respective owner or a person that they will attack
More Information: The zombie Is being cloned from replicastorage The pathfinding appears to stop when being cloned from replicastorage
Script:
local NPC = script.Parent
local PathFindingService = game:GetService("PathfindingService")
local player
game.Players.PlayerAdded:Connect(function(client)
player = client
end)
repeat wait() until player ~= nil
while wait() do
local Path = PathFindingService:CreatePath()
Path:ComputeAsync(NPC.Torso.Position, player.Character.PrimaryPart.Position)
if Path.Status == Enum.PathStatus.Success then
local Waypoints = Path:GetWaypoints()
for i,v in pairs(Waypoints) do
local Position = Instance.new("Part", workspace)
Position.Position = v.Position
Position.Anchored = true
Position.CanCollide = false
Position.Size = Vector3.new(1,1,1)
NPC.Humanoid:MoveTo(Position.Position)
NPC.Humanoid.MoveToFinished:Wait()
Position:Destroy()
end
end
end

2 comments
By the way instead of using while wait do use game:GetService("RunService").Heartbeat:Connect(function() to make it run every frame!
Okay!