Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Help with Cloud Variables
- thecoder114
-
6 posts
Help with Cloud Variables
Hi,
I’m working on a multiplayer tic tac toe game, but some of the the cloud variables don’t seem to be updating. I’m only using numbers and the other variables work well. This is my first time making an online multiplayer game so I’m having some trouble. Does anyone know what could be wrong?
Here is a link to my project in Turbowarp, since it isn’t shared yet. https://turbowarp.org/625429776
I only programmed the top left square to work in online mode so far.
Thanks in advance
I’m working on a multiplayer tic tac toe game, but some of the the cloud variables don’t seem to be updating. I’m only using numbers and the other variables work well. This is my first time making an online multiplayer game so I’m having some trouble. Does anyone know what could be wrong?
Here is a link to my project in Turbowarp, since it isn’t shared yet. https://turbowarp.org/625429776
I only programmed the top left square to work in online mode so far.
Thanks in advance

- deck26
-
1000+ posts
Help with Cloud Variables
You need to allow 0.1 seconds between cloud writes, even to different variables. So when you write to cloud variables in consecutive blocks that's far too fast.
I only had a quick look but struggled to see what you were trying to do. Care to explain your method?
You don't require anything to work quickly in a game like this so if I was doing this I'd probably use a single variable for the grid - eg 001221002 using 0 for unplayed square, 1 for X and 2 for O. That can easily be extracted to a list for local use and written back to the cloud just by assigning the list to the cloud variable.
I only had a quick look but struggled to see what you were trying to do. Care to explain your method?
You don't require anything to work quickly in a game like this so if I was doing this I'd probably use a single variable for the grid - eg 001221002 using 0 for unplayed square, 1 for X and 2 for O. That can easily be extracted to a list for local use and written back to the cloud just by assigning the list to the cloud variable.
- thecoder114
-
6 posts
Help with Cloud Variables
Thanks for replying! I’ll be sure to check and put enough time between cloud writes. And using a list is a great idea! Thank you!
What I was trying to do was have a variable listing all of the coordinates with x and another for o, and then writing that to the cloud every time a new square is clicked. For example, x-positions could be 162 representing Xs on the first, sixth, and second squares on the grid. But those variables were not updating and therefore didn’t work between devices. Thanks again!
What I was trying to do was have a variable listing all of the coordinates with x and another for o, and then writing that to the cloud every time a new square is clicked. For example, x-positions could be 162 representing Xs on the first, sixth, and second squares on the grid. But those variables were not updating and therefore didn’t work between devices. Thanks again!
- deck26
-
1000+ posts
Help with Cloud Variables
That makes more sense now - I saw you were appending 1 to the x or y variable but if you did that for each square it wouldn't make sense. For whatever reason I didn't think of you using 2 for square 2, 3 for square 3 etc so you'll see why I was confused. Thanks for replying! I’ll be sure to check and put enough time between cloud writes. And using a list is a great idea! Thank you!
What I was trying to do was have a variable listing all of the coordinates with x and another for o, and then writing that to the cloud every time a new square is clicked. For example, x-positions could be 162 representing Xs on the first, sixth, and second squares on the grid. But those variables were not updating and therefore didn’t work between devices. Thanks again!
If you use my idea a single cloud variable can control everything including the next player value - just make that letter/item 10 in the variable/list.
The main thing to watch is that you don't assume games will always end cleanly. Someone might lose their internet connection or just decide to give up if they can see they are going to lose! So managing player slots so you can detect when someone disconnects would be sensible.
- deck26
-
1000+ posts
Help with Cloud Variables
You could also switch to using clones rather than separate sprites for the squares. Saves repeating code. Just need a cloneID so each clone knows which square it represents.
- thecoder114
-
6 posts
Help with Cloud Variables
I implemented the your idea and the cloud variables are playing in real time now! 
I’m still having an issue with the code but I’ll hopefully get everything figured out soon. Again, thank you so much for your help!

I’m still having an issue with the code but I’ll hopefully get everything figured out soon. Again, thank you so much for your help!
- Discussion Forums
- » Help with Scripts
-
» Help with Cloud Variables