Variable not incrementing

I am new to this and building an app to ask a 10 questions and award ten point for a correct answer. The question number is incrementing fine but the variable score remains zero. I


have been struggling to see what the problem is. screen dump is attached I think

From the few blocks you shared, the score should change by 10 when you submit the text input but only IF the text input exactly equals the two values added together.

The problem is that the text input’s “Text” is a text string while N1’s Text + N2’s Text is a number. They are never going to equal each other.

To fix this, add zero to Text_Input3’s Text before comparing it to the other sum.

1 Like

Not only that hé uses the wrong set variable Block

Hé uses:

Screenshot_20210607-185514_Chrome

Instead of:

Screenshot_20210607-185524_Chrome

2 Likes

You’re right! Good catch. The way you have it set up, @adalathussain51xs42e, you are telling Thunkable that you want to set the variable with the name of the value in app variable SCORE. So if the score is 0, you would be trying to set the variable named “0”.

Instead of using that block, try the change variable by block near the top of the Variables drawer.

2 Likes

Thanks for replying. The input requested is a number because it is maths problem. The user enters a number into input.

The reason I have used that block because the other is not there. The QuestNo is there but SCORE is not.

Comparison work fine on inserting a correct answer it responds visually and orally . The SCORE variable does not increment.

It’s a drop down menu click on it and you can change the variable.
Your current code creates a new variable variable 0 with the score as it’s value.

Just because you type in a number like 45 into a text input component doesn’t make it a “number” type in Thunkable. It will still be a text string.

The easiest way to show this is to have two text input components and compare their values to see if one is greater than the other.

If you type 22 into the first and 100 into the second and then check to see if 22 > 100, you will see that it returns true because “22” comes after “100” alphabetically.

But if you convert each text input value to a number by adding zero to each and then compare the two new values, you will see that 22 > 100 is now false.

2 Likes

You are right. I did not realise you could do this to variable on left hand side of screen. It now works since I changed existing variable with drop down menu.I learnt some new today.Thanks for your reply.

3 Likes

You’re welcome