-- your code goes here local function battle() -- All of this is 100% unfinished, by the way n = math.random(10) + 1 -- Everybody's HP, enemy HP randomly generated number from 10 to 100 enemyhp = 10*n herohp = 100 io.write("Your HP: ") io.write(herohp) io.write(" ") io.flush() io.write("Enemy HP: ") io.write(enemyhp) io.write(" ") io.flush() if enemyhp <= 0 then print("You won!") end end local function attack() -- Attacking the enemy or running away print("|Attack|Flee|") input = io.read() if input == "attack" then -- This is where my error is attackdamage = math.random(51) if attackdamage == 51 then print("Critical Hit!") enemyhp = enemyhp - 100 else enemyhp = enemyhp - attackdamage print("Enemy took ") io.write(attackdamage) io.write(" damage!") end elseif input == "flee" then print("You ran away!") end end