local enemy = script.Parent
local pathfinding = game:GetService('PathFindingService')
table.foreach(game.Workspace:GetChildren(),
	function(i,v)
		if v.Level ~= nil and v.PlayerGui.CanBeAttacked == true then
			searching = true
			while searching do
				wait(.1)
				local distance = (enemy.Torso.Position-v.Torso.Position).magnitude
				if distance <= 75 and distance >= 2 then
					searching = false
					function moveto(path)
						local points = path:GetPointCoordinates()
						for _, point in pairs(points) do
							enemy.Humanoid:MoveTo(point)
							repeat
								far = (enemy.Torso.Position-point).magnitude
								wait()
							until distance < 2
						end
					end
					local path = pathfinding:ComputeRawPathAsync(enemy, v, 500)
					moveto(path)
				end
			end
		end
end)