# When i try to add points when clicked on button it shows NaN?

**URL:** https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469
**Category:** Questions about Thunkable X
**Tags:** beginner, help
**Created:** [June 1, 2023, 7:56am UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469 "2023-06-01T07:56:28Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![rahulnearj23235tv3](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@rahulnearj23235tv3](https://community.thunkable.com/u/rahulnearj23235tv3)
#### Post date: [June 1, 2023, 7:56am UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/1 "2023-06-01T07:56:28Z")

</div>

I made a button named ad1 and also a label named point count i also did some blocks but when i try.It doesn’t work it says NaN.i also initialiased variable (stored) so that when i click on ad1 it add 10 points and stays in the same place means even if i cut that app and reopen it should store. Please help.

![point](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/9/d9f1aa6ddaba1159f40832fc9d47bf624f219c16.png)

 ![point1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/2/920b37f00237f2d07055b7836c666f1efb94761e.png)

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [June 1, 2023, 12:56pm UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/2 "2023-06-01T12:56:19Z")

</div>

It would be helpful if you posted a link to your project.

You have not assigned anything to `stored variable Pointcount` so that is not going to get saved to the device.

Also, when you use a stored variable, you have to check if its value is null (when screen opens) and if it is, assign it a starting value such as 0.

---

<div class="post-metadata">

### Author: ![rahulnearj23235tv3](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@rahulnearj23235tv3](https://community.thunkable.com/u/rahulnearj23235tv3)
#### Post date: [June 2, 2023, 3:08am UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/3 "2023-06-02T03:08:53Z")

</div>

i did as you said but still shows NaN. here are some screenshots and link of the project.

 ![newp1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/7/27eddc96eb86d0b9907fe9be8551b5aa3963c77b.png)  
 ![newp12](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/9/f9908d05350d340908b8d6c147e3feef962e9524.png)

[https://x.thunkable.com/copy/958c30190f7cc653efe5fcc8f04b292c](https://x.thunkable.com/copy/958c30190f7cc653efe5fcc8f04b292c)

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [June 2, 2023, 5:40am UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/4 "2023-06-02T05:40:29Z")

</div>

The two variables shown with the yellow arrows need to be the **same** variable

 ![f9908d05350d340908b8d6c147e3feef962e9524](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/4/445fe733d81276f14d8ba43492a13395e3b8115d.png)

And at the bottom of the screenshot, you are setting `disableTimestampadone` twice when you should be setting `Pointcount` for the second block.

Also, if you set a stored variable and then change the value being stored, that’s the wrong order. You should set `stored variable Pointcount` to `stored variable Pointcount - 10` and then set `Points count's Text` to `stored variable Pointcount`. Otherwise, you are only changing the value being displayed… you’re not changing the value being saved to the device.

---

<div class="post-metadata">

### Author: ![rahulnearj23235tv3](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@rahulnearj23235tv3](https://community.thunkable.com/u/rahulnearj23235tv3)
#### Post date: [June 2, 2023, 8:58am UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/5 "2023-06-02T08:58:49Z")

</div>

![point count1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/f/5fcc1fa48ac9d9f2b6a67de2972f2cd198d8b021.png)

This is the code i did and it also worked but there are fews problems -

1- When i click on ad1(button) point shows 10 but when i press back the time automatically gets vanish means there are no points shown. i don’t why and might be they get auto reset at 0 i think.

2 - i want that when i click on ad1 it should add point and it did . but when i click on button 2 it should add 10 points to that point which is already there … Elobrate/Explanation

made a button named ad1 ok and ad2 ok  
now when i click on ad1 it shows 10 point ok but doesn’t add 10 point when i click on ad2 to the same points which came on clicking on ad1 button. thankyou sir for helping out.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [June 2, 2023, 2:56pm UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/6 "2023-06-02T14:56:52Z")

</div>

Can you post an updated screenshot and a new link to your project?

---

<div class="post-metadata">

### Author: ![rahulnearj23235tv3](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@rahulnearj23235tv3](https://community.thunkable.com/u/rahulnearj23235tv3)
#### Post date: [June 2, 2023, 3:16pm UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/7 "2023-06-02T15:16:05Z")

</div>

[https://x.thunkable.com/copy/fdb9750423ede8981c6413368471ccde](https://x.thunkable.com/copy/fdb9750423ede8981c6413368471ccde)

These screenshots are updated one I took them when i did some blocks after you said sir.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [June 2, 2023, 3:49pm UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/8 "2023-06-02T15:49:43Z")

</div>

But you are mentioning event blocks (ad1 click, ad2 click) that were wrong in the last screenshot and you didn’t provide an updated screenshot. So that’s why I asked for a project link.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [June 2, 2023, 3:54pm UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/9 "2023-06-02T15:54:34Z")

</div>

You are using different variables to save the points:

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/4/74198c3ecd7764a639802445df3f5205fc979d8d.png)

If you want the Ad1 and Ad2 buttons to add points to the same sum then you need to use a **single** variable for that.

---

<div class="post-metadata">

### Author: ![rahulnearj23235tv3](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@rahulnearj23235tv3](https://community.thunkable.com/u/rahulnearj23235tv3)
#### Post date: [June 3, 2023, 4:11am UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/10 "2023-06-03T04:11:31Z")

</div>

Things are working everything is working now I fixed with the help of yours sir.

But only one problem.

When i click on button they count points but when i press back and re enter that screen points aren’t visible. Help me fix this thing please

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [June 3, 2023, 5:37am UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/11 "2023-06-03T05:37:27Z")

</div>

Do you have blocks that say when screen opens, set label’s text to stored variable Pointcount2?

If so, post a screenshot of those blocks.

---

<div class="post-metadata">

### Author: ![rahulnearj23235tv3](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@rahulnearj23235tv3](https://community.thunkable.com/u/rahulnearj23235tv3)
#### Post date: [June 3, 2023, 5:37am UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/12 "2023-06-03T05:37:27Z")

</div>

Also I want to make a button when we click on that button points should get zero. Please tell me blocks so that I can make this possible

---

<div class="post-metadata">

### Author: ![rahulnearj23235tv3](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@rahulnearj23235tv3](https://community.thunkable.com/u/rahulnearj23235tv3)
#### Post date: [June 3, 2023, 5:38am UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/13 "2023-06-03T05:38:07Z")

</div>

Ok sir wait I’m posting screenshots

---

<div class="post-metadata">

### Author: ![rahulnearj23235tv3](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@rahulnearj23235tv3](https://community.thunkable.com/u/rahulnearj23235tv3)
#### Post date: [June 3, 2023, 5:42am UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/14 "2023-06-03T05:42:37Z")

</div>

These are the screenshots sir.

 ![Screenshot_2023-06-03-11-11-10-46_40deb401b9ffe8e1df2f1cc5ba480b12](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/a/ea9291e4bbddf2194e0589e29029428805fa3485.jpeg)

I haven’t set label set - when screen opens…

---

<div class="post-metadata">

### Author: ![rahulnearj23235tv3](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@rahulnearj23235tv3](https://community.thunkable.com/u/rahulnearj23235tv3)
#### Post date: [June 4, 2023, 2:54am UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/15 "2023-06-04T02:54:12Z")

</div>

Sir please help.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [June 4, 2023, 6:11am UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/16 "2023-06-04T06:11:45Z")

</div>

> [@rahulnearj23235tv3](#):
>
> I haven’t set label set - when screen opens…

Then I would do that…

And if you want to set a variable to zero, then try to set up blocks for that. If you have trouble, post a new screenshot.

---

<div class="post-metadata">

### Author: ![rahulnearj23235tv3](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@rahulnearj23235tv3](https://community.thunkable.com/u/rahulnearj23235tv3)
#### Post date: [June 4, 2023, 7:17am UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/17 "2023-06-04T07:17:08Z")

</div>

Sir what blocks can you please elaborate? Actually I am just a beginner so can you please tell me blocks which i need to setup?

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [June 4, 2023, 2:36pm UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/18 "2023-06-04T14:36:47Z")

</div>

You can watch the Variables tutorial video here: [Variables - Thunkable Docs](https://docs.thunkable.com/variables)

It will explain how to use them.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)
#### Post date: [September 2, 2023, 2:37pm UTC](https://community.thunkable.com/t/when-i-try-to-add-points-when-clicked-on-button-it-shows-nan/2446469/19 "2023-09-02T14:37:04Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
