So this Is a script I made that follows the player:

local NPC = script.Parent

local function FindTarget()
	local maxDistance = 10000
	local target = nil
	for i,v in pairs(workspace:GetChildren()) do
		if v:FindFirstChild("Humanoid") then
			if (v.Head.Position-NPC.Head.Position).magnitude < maxDistance then
				target = v.Head
			end
		end
	end
	return target
end

while wait(0.001) do
	local target = FindTarget()
	if target then
		NPC.Humanoid:MoveTo(target.Position)
	end
end

And as the name says, the script stops whenever the zombie Is cloned In ReplicatedStorage. Got any Ideas?

1 comment

0

Any type of scripts except ModuleScript don't work on ReplicatedStorage or ServerStorage.