As I know, there was a bug with saving on player leave. Be sure to download the most recent version.
Another possible reason that “API services” is not enabled for your project in Studio.
Go to game settings / security / Enable Studio Access to API Services and set it to True.
To test, try to add a “manual save” line:
NatureStore:ApplyPlayerData(plr.UserId)
As Apafey said.
Check if you have the latest version (you can see the version in the modulescript, the latest one is the 15 Dec)
Also make sure to Enable Studio Access To API Services
This is a resource that has data saving methods worse than ProfileService but functionality better than ProfileService.
You have essentially the same concept as ProfileService with your saving method (creating a table that stores data and whatnot). My question to you is why not take ProfileService, utilize it’s data saving methods (while obviously making sure to credit the github and its contributors MadStudioRoblox/ProfileService: Universal session-locked savable table API (github.com) ), and then proceed to add your custom functionality to it?
This is a universal compromise and a win-win for everyone. ProfileService’s name and contributors gets spread even more, your module becomes 10 times more reliable for data saving and all of this at no expense to any of the parties involved.
Just be sure to double check with Mad Studio (or loleris considering he’s the lead developer) if they are okay with permitting you to use ProfileService in this case.
To be honest, I don’t understand how ProfileService works.
I’m really bad at understanding other’s codes, that’s why I don’t want
to use ProfieService as a “base code”.
But, if there’s anything I could implement to make NatureStore more reliable, please let me know!
Because, it’s better than DatastoreX.
DatastoreX is my old module, NatureStore is a completly new and better module.
DSX is basically the same as the built-in DatastoreService.
But NatureStore has some really nice improvements and it’s very easy to learn!
Such an amazing datastore module, easy to understand, I just added global functions for setting player’s value and a bindable function to listen to player’s data changes. SMOOTH!
-- This is your datastore script --
local NatureStore = require(game.ServerStorage.NatureStore) -- Require NatureStore, I suggest to put it in ServerStorage
NatureStore:SetTemplate({
Inventory = {} -- By default, they have nothing
--here are the other things you save...
})
local itemStorage = game.ReplicatedStorage.Items -- You must store all your items somewhere. (I suggest ReplicatedStorage!)
-- 'game.ReplicatedStorage.Items' should be a folder! You can change this path by the way.
game.Players.PlayerAdded:Connect(function(plr)
local data = NatureStore:Get(plr.UserId) -- Load the player's data
local value = data.Value
local loadedInventory = data.Inventory
for _, itemName in pairs(loadedInventory) do
if itemStorage:FindFirstChild(itemName) then -- check if it exists
local item = itemStorage[itemName]:Clone()
item.Parent = plr.Backpack
end
end
plr.Backpack.ChildAdded:Connect(function()
saveInventory(plr)
end)
plr.Backpack.ChildRemoved:Connect(function()
saveInventory(plr)
end)
end)
function saveInventory(plr) -- it doesn't actually save it to the datastore!
local backpack = plr.Backpack -- I assume that you use the default Roblox inventory system (aka. Backpack)
local savedInventory = {}
for _, item in pairs(backpack:GetChildren()) do
table.insert(savedInventory, item.Name) -- makes sense
end
NatureStore:SetPlayerDataKey(plr.UserId, "Inventory", savedInventory)
end
game.Players.PlayerRemoving:Connect(function(plr)
saveInventory(plr)
NatureStore:ApplyPlayerData(plr.UserId) -- save when the player leaves
end)
NatureStore:DoAutosave(30) -- do autosaving every 30 seconds, just for sure
I haven’t said to use this over ProfileService. If you like that syntax better, use it! You could give a try to NatureStore, if it doesn’t work out for you there’s nothing wrong with it.
Use whatever you wish for.
I was also wanting to report an issue
For some reason, if a Premium player has stats saved
all newer players will have their stats saved to that premium player’s stats (if that premium player is in the server with them)
No idea what is causing it, I have code that detects if somebody has a premium, but It should only apply to that one person since it gets its user ID
Also I’ve seen The NatureStore:IncrementData function applying and then instantly unapplying, no idea what is causing that
Does NS write datastores when the player leaves or when the server closes?
Roblox can ratelimit datastores if used too much in one instance, therefore a caching system would be a logical move and to set all the data in a server at once?
Does NS utilise a caching system or just set data when the player leaves?
I really hope theres a client side saving stuff which can save player module in replicated storage while the player can easily edit the module by click some button