Specific datastore not working

I have multiple datastores for peoples stats, and all of them work except two, my level and xp stats though theyre all set out the exact same unless im missing something so im unsure why.

This is where the players stats are saved when they leave:

This is where the data is set:

And this is where the data is loaded:

Any help would be really appreciated

Far too many DataStores, try tabularizing it all into a single DataStore and save to/load from there instead.

You’re likely overstepping the DataStoreService limits.

3 Likes

Similar to what is being said by @Forummer, it is likely that you are making too many individual requests to the Datastore, I don’t know what the exact limits are specifically but I know nonetheless that Roblox restricts the amount of requests you can make to a datastore.

As a result, it would be much more efficient to create a dictionary and put all your data in it instead. Then you can add this dictionary to the datastore with a unique identifier representing the player (such as the UserId) as the index. This means you can save all your data by calling the :SetAsync() method only once, highly efficient in my opinion; thus significantly reducing the amount of requests made to the Datastore.

When you want to retrieve your data, you can call the :GetAsync() method and it will return the data we saved to the data store. In this case, the method will return the dictionary which will contain all of your data in one place as shown below:

local dss = game:GetService("DataStoreService")
local dataStore = dss:GetDataStore("dataStore")
local player = -- Assume that this variable contains a player in the game for example sake.

local success, data = pcall(function()
   return dataStore:GetAsync(player.UserId)
end)

if success and data then
   player.leaderstats.Gold.Value = data[Gold] -- Taking our leaderstats and setting them to values in the dictionary
   player.leaderstats.Points.Value = data[Points]
elseif success and not data then
   player.leaderstats.Gold.Value = 0
   player.leaderstats.Points.Value = 0
else
   warn(data)
   -- There was an error loading the data
end

-- Etc, etc
1 Like