This is Exercise 2.22 from Rudin's Real and Complex Analysis. I can't prove this in the case where $f$ may take infinite values.
Suppose that $X$ is a metric space with metric $d$, and that $f:X \to [0,\infty]$ is lower semicontinuous, $f(p)<\infty$ for at least one $p \in X$. For $n=1,2,3,\dots, x \in X,$ define $$g_n(x)=\inf \{f(p)+nd(x,p):p\in X\}$$ and prove that (i) $|g_n(x)-g_n(y)| \le nd(x,y),$ (ii) $0\le g_1 \le g_2 \le \cdots \le f,$ (iii) $g_n(x)\to f(x)$ as $n\to \infty$, for all $x \in X$.
I can prove this in the case $f$ is finite-valued. (i) and (ii) are easy whether or not $f$ is finite-valued. For (iii), let $\epsilon>0,$ and for each $n$ we can choose $z_n \in X$ such that
$$ g_n(x)+\epsilon > f(z_n)+nd(x,z_n)\ge nd(x,z_n).$$ But $g_n(x)+\epsilon \le f(x)+\epsilon$, and it follows that $d(x,z_n)\to 0$. (Here is where we use that $f$ is finite valued.) Since $f$ is LSC, $\liminf_{n\to \infty} f(z_n)\ge f(x);$ thus $f(z_n) > f(x)-\epsilon$ eventually. But now $$g_n(x) > f(z_n)-\epsilon + nd(x,z_n) \ge f(z_n)-\epsilon >f(x)-2\epsilon$$ for large enough $n$. Hence we have $g_n \to f$ pointwise.
The problem is this proof only works when $f$ does not take $\infty$ for any $x$. How can I prove this in the specific case of the exercise, i.e., with only the assumption that $f(p)<\infty$ for at least one $p \in X$?
Let $x\in X$ be such that $f(x)=\infty$. Assume that $(g_n(x))_n$ (a nondecreasing sequence) does not go to $f(x)$. Then it is bounded by some $M$.
For each $n$, there is thus some $z_n$ such that $nd(x,z_n) \leq f(z_n)+nd(x,z_n) \leq M+1$.
Thus $z_n \rightarrow x$. Thus $ \lim\inf f(z_n) \geq f(x)=\infty$, ie $M+1 \geq f(z_n) \rightarrow \infty$. A contradiction.