Expected an expression that can fail in the 'if' condition clause Error

Why am I getting the error “Expected an expression that can fail in the ‘if’ condition clause” on my code. The condition can fail, so I am lost to why I am getting this error, especially since if I put the code in my Add Death function it works. Is it because I am not changing the value of lives? Any help would be appreciated.

AddDeath():logic=
set lives -= 1
return IsLastLife()

IsLastLife():logic=
    if(lives > 1):
        return false

    set TeamIndex -= 1
    return true
      
AddLife(e:int): void=         
    if(IsLastLife()):
        set TeamIndex += 1       
    set lives += 1

Try if(IsLastLife() = true):

Thanks but I figured it out, I had to initialize a new variable for it to work like this,
AddLife(e:int): int= #Returns the new team index
arg := IsLastLife()
if(arg?):
set TeamIndex += 1
set lives += 1