Hello! I made this script thanks to a YT video:
local maxDistance = 100000
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~~
Anyway there Is a problem (Well two but lets do the one I actually wanna do). So I want the NPC to know how to do mazes, a example would be where the NPC sees a player behind the wall and needs to turn around the wall to get the player
