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!
Thank you! I’m glad you like it!
Yes, that’s why I created it in the first place. I use it myself!
Hey Was Wanting To Ask
Can you create inventory lists with this? If so could you send some example code here?
Thanks, Absolutely Loving This Plugin
Of course you can!
It depends on you game. But I’ll try.
-- 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
Haven’t tested it, but it should work.
Sick! Exactly what I needed, Thank you.
It looks interesting… but I don’t see why I’d use this over ProfileService, since it has more features
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
those are a few issues I’ve come in contact with
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
Found my issue from the Premium Player, Apparently, color values are not supported
How would I be able to reset a datastore?
Sorry for the bump, great module. Although this example doesn’t work.
local store = require(game.ReplicatedStorage.Modules.NatureStore)
local Template = {
Leaderboard = {
Coins = 100;
Rank = "Noob";
Steps = 0;
};
Multiplier = 1;
MaxSpeed = 100;
CoinBonus = 0;
}
store:SetTemplate(Template)
store:AutoLeaderboard(Template.Leaderboard)
game.Players.PlayerAdded:Connect(function(plr)
store:Get(plr.UserId)
end)
Gets that error on line 258.
(I did this again because I realized I replied to the wrong person) Sorry!
As a strong hater of ProfileService/DataStore2, I include this module in my commissions whenever I need to use datastores - I still haven’t bothered with writing up an entire module, ever - and it’s been a great help :]
Also, small issue that can be fixed easily,
Even Roblox knows what you did
AutoLeaderboard same as Auto made leaderstats and every in player Data will create the instance except table type and that freq argument is time delation to to update all players leaderstats (with loop)