Why doesn't the data store work?

I have a script that should theoretically store the value that should be displayed on all servers and be there the same, for example, let it be 10. I have a script that, when clicked, changes this value to, for example, 9. But this script when you enter the game says that the value is 0. Although if you look at it in the studio, you will see that it is 10. WHY? HELP!!!

Do you have Studio Access to API Services enabled? If not, you can enable it in the game settings, in the tab Security.

1 Like

I have everything enabled, that’s not the problem, because my clicks are saved. But the value for the whole game is not)

Are you getting errors in the game? (Not in studio’s console, but the in-game dev console.)

The code should be working. Does your code for the “EggHealth” text (I assume it is text…) loop, and continuously change the value? Or does it only set it once? If it does only set it once, add a while loop. (With a small delay, of course.)

Roblox studio tends to shutdown and start servers a lot quicker than the client, which is why your PlayerAdded event probably is running faster, making it work in studio.

Found the problem. It’s because you are saving a table, and not an actual value.

local Savetable = {game.ReplicatedStorage.EggHealth.Value}

In this line you use the {}, which means you assigned Savetable as a table.
Instead of that, you should use:

local Savetable = game.ReplicatedStorage.EggHealth.Value

Also replace the local NumbersForSaving , since that is also a table.

If this didn’t help you, try visiting Roblox Studio GlobalDataStore Documentation