signs={"+","-"}
score=0
while true do
v1=math.random(1,10)
v2=math.random(1,10)
s=signs[math.random(1,#signs)]
answer=tostring(v1…s…v2)
answer=tonumber(answer)
problem=tostring(v1…s…v2)
print(problem…"=?")
guess=tonumber(io.read())
print("\n")
if guess==answer then
print(“correct! +100pts”)
score=score+100
else
print(“sorry, but the answer was “…answer…”. -50pts”)
score=score-50
end
end
mathgame.lua:9: attempt to concatenate global ‘answer’ (a nil value)
The end goal is to randomly generate math problems for the user to solve. I’m kind of a Lua newb and this is my 2nd application.