# Setting and Getting Stored Variables - Keep getting Null

**URL:** <https://community.thunkable.com/t/setting-and-getting-stored-variables-keep-getting-null/2856079>\
**Category:** Questions about Thunkable X\
**Created:** [February 26, 2024, 1:48am UTC](https://community.thunkable.com/t/setting-and-getting-stored-variables-keep-getting-null/2856079 "2024-02-26T01:48:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![thorntonp72l3](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/thorntonp72l3/32/170888_2.png) [@thorntonp72l3](https://community.thunkable.com/u/thorntonp72l3)\
**Post date:** [February 26, 2024, 1:48am UTC](https://community.thunkable.com/t/setting-and-getting-stored-variables-keep-getting-null/2856079/1 "2024-02-26T01:48:37Z")

</div>

Hi,

I am trying to persist some stored variables by setting and getting them, but for some reason I keep getting a null value returned. I have followed a few threads and tried to replicate this but cannot seem to get the value.

![thunk_1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/c/0c310e3a4d391423632997d6b3f93679a168aafa.png)

![thunk_2](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/f/4f2ac9902a3f1dd6f6f6fc9aaac93a2bff52ac65.png)

The screen is not the main screen so it opens once I click on a button to go there, not sure if that makes any difference and it’s null on my android and pc test.

I also tried a text value incase it did not like a Boolean.  
 ![thunk_3](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/d/6d9899da9cb8ffb0a9e445b9074273e9f66d4318.png)

Any help would be appreciated.

Thank you,

Paul

---

<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:** [February 26, 2024, 2:21am UTC](https://community.thunkable.com/t/setting-and-getting-stored-variables-keep-getting-null/2856079/2 "2024-02-26T02:21:57Z")

</div>

You need to stop using the `set stored variable " "` block.

That block is for dynamic variable names. So when you put the `stored variable test_sr_gm` block in where the variable name should be, you’re telling Thunkable to get the value of a variable with the value from the stored variable. So let’s say that `stored variable test_sr_gm` has the value “43”. Your blocks would be attempting to reference a stored variable called 43. But that doesn’t exist so you see “null”.

Instead, use the `set variable` block at the **top** of the variables drawer.

---

<div class="post-metadata">

**Author:** ![thorntonp72l3](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/thorntonp72l3/32/170888_2.png) [@thorntonp72l3](https://community.thunkable.com/u/thorntonp72l3)\
**Post date:** [February 26, 2024, 2:40am UTC](https://community.thunkable.com/t/setting-and-getting-stored-variables-keep-getting-null/2856079/3 "2024-02-26T02:40:34Z")

</div>

HiTatiang,

Thanks for responding to my query. Sorry but I am completely confused by that. I am not sure then how I would actually set a default value if it does not exist. I am still learning on the whole block config.

I tried this, but that did not work either.  
 ![thunk4](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/7/676ad7233563186357c6e193eccedc567f6ce6bd.png)

I then put the set variable at the top of the block, but that was the same.  
 ![thunk5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/8/68b81a22356f8393b30449b9e555730a3178f49a.png)

Still learning sorry.

Thank you

---

<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:** [February 26, 2024, 4:03am UTC](https://community.thunkable.com/t/setting-and-getting-stored-variables-keep-getting-null/2856079/4 "2024-02-26T04:03:16Z")

</div>

You should be using variables this way:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/e/8eecde30784e26c4b4766d0c6122e3979cc3ee6a.png)

---

<div class="post-metadata">

**Author:** ![thorntonp72l3](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/thorntonp72l3/32/170888_2.png) [@thorntonp72l3](https://community.thunkable.com/u/thorntonp72l3)\
**Post date:** [February 26, 2024, 4:21am UTC](https://community.thunkable.com/t/setting-and-getting-stored-variables-keep-getting-null/2856079/5 "2024-02-26T04:21:35Z")

</div>

Hi Tatiang,

Rightio. I got you now. Yes that makes more sense and thank you for taking the time to explain it for me.

It works great now.

Thank you very much.

---

<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:** [February 26, 2024, 11:33pm UTC](https://community.thunkable.com/t/setting-and-getting-stored-variables-keep-getting-null/2856079/6 "2024-02-26T23:33:39Z")

</div>

You’re welcome. You can help others by clicking the solution checkbox for my post.

---

<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:** [May 26, 2024, 11:34pm UTC](https://community.thunkable.com/t/setting-and-getting-stored-variables-keep-getting-null/2856079/7 "2024-05-26T23:34:23Z")

</div>

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