Get and update cloud variable

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 ?

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.

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 ?

to give you a context, this doesnt work :


Capture d’écran, le 2025-01-11 à 05.12.48

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.

I prefer the method shown in this topic: Cloud variables and user ID.