Zombie script not working

So I was watching TheDevKing’s magnitude tutorial and he was making a script that makes a zombie walk around aimlessly and when a player is within range it starts chasing them. Everything was working perfectly for him but for me, nothing was even happening, not even any errors in output. I’m not sure if it’s because the tutorial is from 2019, but I need some help.

Script:

local zombieTorso = script.Parent.Torso
local zombieHumanoid = script.Parent.Humanoid

local function findTarget()
	local agroDistance = 100
	local target = nil
	for i, v in pairs(game.Workspace:GetChildren()) do
		local human = v:FindFirstChild('Humanoid')
		local torso = v:FindFirstChild('Torso')
		if human and torso and v ~= script.Parent then
			if (zombieTorso.Position - torso.Position).Magnitude < agroDistance then
				agroDistance = (zombieTorso.Position - torso.Position).Magnitude
				target = torso
			end
		end
	end
	return target
end

while wait(1) do
	local torso = findTarget()
	if torso then
		zombieHumanoid:MoveTo(torso.Position)
	else
		zombieHumanoid:MoveTo(zombieTorso.Position + Vector3.new(math.random(-50, 50), 0, math.random(-50, 50)))
	end
end

Is the zombie anchored at all?

This script looks like it will only work when the game is in R6 mode. Is the game set to R15?

I was thinking of that, but he said it isn’t even doing anything.

If it was R6 it would return nil and would not pass the checks. Try adding a print statement after

if human and torso and v ~= script.Parent then

and see if it appears in the output.

Also, I would recommend using the HumanoidRootPart :]

No the zombie is an R6 rig from the default plugin.

Oops, the humanoid root part was anchored but when I unanchored it the zombie started moving. Thanks!