Not all shells define a variable `UID`. This is a bash and zsh feature only. In other shells, the `UID` variable is not defined, so your test command expands to `[ -ne 0 ]` which is a syntax error.
A portable way to obtain the user ID is with the `id` utility.
if [ "$(id -u)" -ne 0 ]; then …