Issue with Getting NPC to follow. Error start at print(Humanoid)? Above this print works
game.Players.PlayerAdded:connect(function(Player)
local p = game.Workspace:WaitForChild(Player.Name)
print (p)
local f = p.UpperTorso.Position
print (f)
local dist = 15
local pos1 = f
for i,v in pairs(game.Workspace.CrystalMobA.UndeadWarrior:GetChildren())do
if v.Name == "HumanoidRootPart" then
print (v)
local z = v.Parent.Humanoid
local pos2 = v.Position
local magnitude = (pos1 - pos2).magnitude
if magnitude <=15 and z then
if p.Humanoid ~= nil then
print('humanoid')
while true do
wait(1)
local target = f(v.Position)
if target ~= nil then
print ("Following")
v.Parent.Humanoid:MoveTo(target.Position, target)
end
end
end
end
end
end
end)