Any lower semicontinuous function $f: X \to \mathbb{R}$ on a compact set $K \subseteq X$ attains a min on $K$.
Lower semicontinuity need not imply intermediate value property(IVP), and a function on a compact interval in $\mathbb{R}$ which satisfies IVP can fail to have the minimum.
But your $\inf = -\infty$ case proof can be elaborated to conclude that $f$ cannot be unbounded below. What you need is the finite intersection property of a compact set. Or, you can just consider the open cover (why?) formed by the open sets $U_c = \{ x : f(x) > c \}$ to obtain the boundedness of $f$.
Here is another possible approach:
Suppose $f$ has no minimum, and let $\alpha = \inf f(K)$. Then for each $x \in K$, we have $\alpha < f(x)$ and there is $\epsilon(x) > 0$ satisfying $$\alpha < f(x) - \epsilon(x).$$ Then by lower-semicontinuity, there exists a neighborhood $U(x)$ of $x$ such that $f(x) - \epsilon(x) < f(y)$ for all $y \in U(x)$. Now $U(x)$ covers $K$, so there are finitely many $x_1, \cdots, x_n \in K$ where $$K \subset U(x_1) \cup \cdots \cup U(x_n).$$ Let $\beta$ be given by $$ \beta = \min \{ f(x_k) - \epsilon(x_k) : k = 1, \cdots, n \}.$$ Then clearly $\alpha < \beta$, and for any $y \in K$, $y \in U(x_k)$ for some $k$ and hence $\beta \leq f(x_k) - \epsilon(k) < f(y)$, which means that $\beta \leq \inf f(K) = \alpha$, a contradiction! Therefore $f$ must attain its minimum at some point in $K$.
So this won't help the person who needed it for homework, but for future visitors, here's an approach which is similar to the one above, but uses a contradiction of compactness.
Suppose $f$ has no minimum in $K$, then $\neg(\exists x\in K)(\forall y\in K)(f(x)\leq f(y))$ which is equivalent to $(\forall x\in K)(\exists y\in K)(f(y)<f(x))$ which is equivalent to $(\forall x\in K)(\exists y\in K)(x\in f^{-1}((f(y), +\infty)))$.
But this means the collection of open sets $\{f^{-1}((f(y), +\infty)):y\in K\}$ is an open cover of $K$.
We claim this open cover has no finite subcover.
Suppose $\{y_1, \cdots, y_n\}\subset K$ is finite, and define $N = \displaystyle\arg\min_{1\leq k\leq n}f(y_k)$, then $\displaystyle\bigcup_{1\leq k\leq n}(f(y_k),+\infty) = (f(y_N), +\infty)$. Then we have $\displaystyle y_N\in K$, but $y_N \notin f^{-1}((f(y_N), +\infty))= f^{-1}(\bigcup_{1\leq k\leq n}(f(y_k),+\infty)) = \bigcup_{1\leq k\leq n}f^{-1}((f(y_k),+\infty))$ and so $\{f^{-1}((f(y_k),+\infty)):1\leq k \leq n\}$ doesn't cover $K$.
This contradicts the compactness of $K$.