I was following with a tutorial from TheDevKing on Magnitude. Here is the code:
local ZombieRoot = script.Parent.HumanoidRootPart local ZombieHumanoid = script.Parent.Humanoid local function findTarget() local agroDistance = 100 for i, v in pairs(game.Workspace:GetChildren()) do local Root = v:FindFirstChild("HumanoidRootPart") local Humanoid = v:FindFirstChild("Humanoid") if Root and Humanoid and v ~= nil then if (ZombieRoot.Position - Root.Position).Magnitude < agroDistance then target = v end end end return target end while wait(1) do local Target = findTarget() if Target ~= nil then print("Found Target!") ZombieHumanoid:MoveTo(target.HumanoidRootPart.Position) end end
There are no errors, but for some reason the zombie does not move to the target.
I also put two characters right beside the zombie to see if it would run the print function and it did but for some reason it did not move to the character.
I'm not sure if something else in my script is wrong or I used the Humanoid:MoveTo() function incorrectly. Please help me out if you what's wrong with my script. Thanks!
I found a solution but it wasn't really obvious. Instead of using the load character plugin, I just went to the tool box and used a free NPC model. I'm not really sure how it made a difference but for some reason it worked.