Hi! I got a question related to datastore2 module and its storing.
So lets look at those two examples:
I run this loop on the first lines of script:
local datastore2 = require(1936396537)
datastore2.Combine("DATA", "money","","","") -- (many more keys)
while wait(2) do
datastore2("money", game.Players.nuttela_for1me):Increment(1000, 0)
wait(0.5)
print(datastore2("money", game.Players.nuttela_for1me):Get())
end
end
prints are doing as aspected and data gets saved, when I join the game again, it starts from where I finished.
2. Doing the same loop after PlayerAdded event
local datastore2 = require(1936396537)
datastore2.Combine("DATA", "money","","","") -- (many more keys)
game.Players.PlayerAdded:Connect(function(plr)
while wait(2) do
datastore2("money", game.Players.nuttela_for1me):Increment(1000, 0)
wait(0.5)
print(datastore2("money", game.Players.nuttela_for1me):Get())
end
end)
At this type of looping prints are doing as aspected, so I could suspect that the data is actually updating and saving, but no! When I rejoin it starts from 0, so that means that data wasnt actually saved once I left the game… and this also occurs if I try with RemoteEvents instead of PlayerAdded event.
Thanks for help!
Are you testing in-studio or in the published place? If it’s in studio you have to add the “SavOnStudio” Value, and be sure “Enable Studio Access to API Services” is turned on.
Yeah I test this in official servers, anyways I discovered that, the bugg only occurs in this place/game. I tested it out in other place and it worked as aspected, which is kinda weird. I was checking if there is any other datastore setting up in my place with search all scripts feature, but didnt find any…
im not sure how many. but datastores have a limit on how much data can be in 1 key.(its large but can be filled)
other option would be to use the “- OnUpdate(callback)” option
every time a datastore updates you can let it run a print to see if something resets it.
keep in mind we have just narrowed down what it can be, not found the cause.