NatureStore | Datastores made easy! | A new Datastore module!

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)

1 Like

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.

2 Likes

I downloaded it just today. But I’m not sure if I have API services on. That’s probably it. Lol thanks!

1 Like

Hello!

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!

1 Like

Why should I use this over DatastoreX ?

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!

1 Like

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!

1 Like

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.

3 Likes

Sick! Exactly what I needed, Thank you.

1 Like

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.

2 Likes

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?

1 Like

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

Hey, I’m not a scripter on Roblox so regarding datastores I’m quite a noob but can I save different things in different templates or will it not work at all? Also I would like to know if I can access the data from the client side, I need it for UIs.

1 Like

How would I be able to reset a datastore?