So this Is a little problem so I made a script that makes the NPC find the player and follows the player:
local function FindTarget()
local maxDistance = 10000
local target = nil
for i,v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") then
if (v.Head.Position-script.Parent.Head.Position).magnitude < maxDistance then
target = v.Head
end
end
end
return target
end
while wait() do
local target = FindTarget()
if target then
script.Parent.Humanoid:MoveTo(target.Position)
end
end
And I made a test part spawner that spawns the NPC (Which Is named Noob btw)
local part = script.Parent
local rep = game.ReplicatedStorage
wait(1)
local NPC = rep.Noob:Clone()
NPC.Parent = game.Workspace
NPC.Position = script.Parent.Position
NPC.Orientation = script.Parent.Orientation
This sadly however makes the NPC not follow the player just Instead stands there, also I founded out that It targets NPCS that are clones from replicatedstorage (I think)
(ALSO the following script does work)
