# Get and update cloud variable

**URL:** <https://community.thunkable.com/t/get-and-update-cloud-variable/3466178>\
**Category:** Questions about Thunkable X\
**Tags:** firebase, design, beginner\
**Created:** [January 10, 2025, 4:44pm UTC](https://community.thunkable.com/t/get-and-update-cloud-variable/3466178 "2025-01-10T16:44:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ocorbo](https://avatars.discourse-cdn.com/v4/letter/o/ad7895/32.png) [@ocorbo](https://community.thunkable.com/u/ocorbo)\
**Post date:** [January 10, 2025, 4:44pm UTC](https://community.thunkable.com/t/get-and-update-cloud-variable/3466178/1 "2025-01-10T16:44:33Z")

</div>

![Capture d’écran, le 2025-01-10 à 11.31.19](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/9/19ef9e24d488017c2c36c7bb92fe020da5bec7e1.png)

im trying to find a way to sort of recursively ‘set and get’ the cloud variable and add 1 to the value of the property ‘playerCount’ when a new user connect via BLE. With the code in the printscreen i can set the value to ‘1’ but if another user connect itself it will not add ‘1’.

How could i achieve that ?

---

<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:** [January 10, 2025, 8:04pm UTC](https://community.thunkable.com/t/get-and-update-cloud-variable/3466178/2 "2025-01-10T20:04:05Z")

</div>

You could do a 2-step approach:

1. Set app variable currentPlayerCount to cloud variable pDSTAL/playerCount
2. Set cloud variable pDSTAL/playerCount to app variable currentPlayerCount + 1

I’m not sure how that would function with many players connecting at once though. You’d need to test it.

---

<div class="post-metadata">

**Author:** ![ocorbo](https://avatars.discourse-cdn.com/v4/letter/o/ad7895/32.png) [@ocorbo](https://community.thunkable.com/u/ocorbo)\
**Post date:** [January 11, 2025, 10:02am UTC](https://community.thunkable.com/t/get-and-update-cloud-variable/3466178/3 "2025-01-11T10:02:12Z")

</div>

but because i ‘set cloud variable’ and never initialized it anywhere i have no block variable related to the cloud value. So, no way to access it as a currentPlayerCount. How do i get the value before ?

---

<div class="post-metadata">

**Author:** ![ocorbo](https://avatars.discourse-cdn.com/v4/letter/o/ad7895/32.png) [@ocorbo](https://community.thunkable.com/u/ocorbo)\
**Post date:** [January 11, 2025, 10:13am UTC](https://community.thunkable.com/t/get-and-update-cloud-variable/3466178/4 "2025-01-11T10:13:41Z")

</div>

to give you a context, this doesnt work :

 ![Capture d’écran, le 2025-01-11 à 05.13.00](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/8/5890a2ecc5b772f3c569896dc47e15a61da41c89.png)  
 ![Capture d’écran, le 2025-01-11 à 05.12.48](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/d/3d20a8ed2cfd90bd5ecb8163ad69a6c46e14b053.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:** [January 11, 2025, 4:05pm UTC](https://community.thunkable.com/t/get-and-update-cloud-variable/3466178/5 "2025-01-11T16:05:03Z")

</div>

You use the `cloud variable " "` block at the _bottom_ of the Variables drawer and enter the path to the cloud variable.

The video in the documentation shows one way to do this with `get property of object` blocks: [Connect a Firebase Realtime Database | Thunkable Docs](https://docs.thunkable.com/blocks/blocks/variables-overview/connect-a-firebase-realtime-database#how-to-read-data-in-a-firebase-realtime-database).

I prefer the method shown in this topic: [Cloud variables and user ID](https://community.thunkable.com/t/cloud-variables-and-user-id/1434493).

---

<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:** [April 11, 2025, 4:05pm UTC](https://community.thunkable.com/t/get-and-update-cloud-variable/3466178/6 "2025-04-11T16:05:26Z")

</div>

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