Zombie not moving to the target

Ok, so I tried to make a zombie move to the player within 100 magnitude, but it doesnt move to the target and doesn’t do anything at all, I tried to debug it by re-writting the code, printing at specific positions, etc… But it didn’t work. (Output also says no errors)

Script here:
local zombie = script.Parent

local zombietorso = script.Parent:WaitForChild(“Torso”)
local zombiehumanoid = script.Parent:WaitForChild(“Humanoid”)

local function checkTarget()
local target = nil
local aggrodist = 100
for i, v in pairs(workspace:GetChildren()) do
local hum = v:FindFirstChild(“Humanoid”)
local torso = v:FindFirstChild(“Torso”)
if torso and hum and (zombietorso.Position - torso.Position).magnitude < aggrodist and hum.Health > 0 and v ~= zombie then
aggrodist = (zombietorso.Position - torso.Position).magnitude
target = torso
end
end
return target
end

while wait(1) do
local torso = checkTarget()
if torso then
print(“Working!”)
zombiehumanoid:MoveTo(torso.Position)
print(“b”)
end
end

2 Likes

Have you unanchored the zombie?

2 Likes

No, I didn’t, but when I un-anchor all the parts of the zombie, only the torso of the zombie moves to the target and everything else just doesn’t move.

2 Likes

And I want the entire parts of the zombie to move to the target.

2 Likes

you might need to rig the zombie if u haven’t already, and make sure every limb is unanchored

2 Likes

I un-anchored every part of the zombie and only the torso moves to the target.

2 Likes

check the motor6d welds, if they’re not welded properly, use a plugin and rig it.

if you individually move a rigged characters limbs, motor6d welds come undone so this may be the case with your zombie

Yes, I fixed the problem now with the rig editor, thank you.

1 Like