Save your player data with ProfileService! (DataStore Module)

Wait I’m confused.

Somebody just told me that data only saves every 90 seconds and now I’m being told that data saves when you leave the game…(???) If both are true then why bother creating a changed function in the first place if the data is going to save at the end?

Precisely, a changed function would be too redundant in my eyes. Using Profile:Release() will trigger a save of the current state. Wherever your module is that is handling the ProfileService, you want to release when the player leaves, or else the profile is never released, causing problems when the profile is being loaded back in when the player joins a session. If you are trying to do Profile:Save(), it isnt for saving Profile.Data so keep that in mind.

1 Like

yes, this is neat and all, but there is datastore2, which is a extremely efficient wrapper in which I use. not trying to say profileservice is bad, but there are better wrappers.

Why do you think DataStore2 is better? Proper feedback is required to make something improve.

1 Like

A citation is needed, but I believe bereza himself (the person who originally came up with the system Datastore2 uses to save data) has already endorsed ProfileService over Datastore2, presumably because of its ability to save data much more safely compared to DS2.

If there is a reason why you think DS2 has pros over ProfileService that haven’t already been mentioned (like backups), please post them here. I would also encourage you to fully educate yourself on the innerworkings of ProfileService and exactly why it’s the best open-source data management module on the forum that I’ve seen.

4 Likes

Personally, instead of using one over other. I use both wrappers . I use Profile Service for things like inventory system so can design my own interface. And use datastore2 for stats like cash as it’s easy to setup.

I’ve used ProfileService for all my projects since its release, and I did not have an issue with it until now. There seems to be a 50% chance that it loads data much slower than usual. Sometimes it takes up to 10 seconds for it to print Set profile sesion data. If this happens, I get this error message in the output. I don’t know what is wrong with my code.

12:50:51.266 [ProfileService]: DataStore API error (Store:“PlayerData#1”;Key:“Player_1045299999”) - “ServerScriptService.ServerLoader.Modules.ProfileService:548: attempt to index nil with ‘UpdateAsync’” - Server - ProfileService:433

My source code: ServerHandler - Pastebin.com

You’ve grabbed a version that had an error in it and didn’t update - this error only existed between December 19’th and 21’st and it should’ve only happened inside studio testing:

Try updating and see if you still get the same error!

2 Likes

There’s been a lot of website outages on Roblox that are starting to become more frequent. Primarily, those outages have included datastores which could harm a user’s data.

How well does this module defend against those outages? Does it do well or is this based on implementation.

all datastore modules rely one normal datastores. So theres no way to stop it I think.

Have you read the documentation?
This module will perform frequent autosaves of a player’s data, and yield when Datastores are down. There is (virtually) no chance of data getting overwritten.

2 Likes

The 2. is wrong if you use :Reconcile which the example loleris gave uses

That post was made before :Reconcile function was added.

3 Likes

Say I wanted to host a testing session for a new game. There is no prior DS history, and only wanted the test to last for a few days and then all data is wiped at the end. What would be the best way to go about this? I was thinking about using .Mock, but I believe it doesn’t save keys. So only things that I can think of are, copy game to new game just for test, or change the keys.

Just use a different ProfileStore name for throwaway saves.

1 Like

Looks good, I took a look at the code and added data compression to it. Which lets me save way more chars than 4 million.

Is it possible to save a table using Global Updates? I want to make it so each time a player hatches a secret a string is added and then I can call the Table and loop through and find the amount of secrets with that name. After that it returns amount of the pet hatched. Or should I use OrderedDatastore?

I’ve been experimenting with this module until I came across this error from the output:

[18:42:11.181 - ServerScriptService.Script:10: attempt to perform arithmetic (add) on nil and number]

I keep getting this error that my data table is nil even though I’ve specified the values already? Even if I change the values up the output remains the same.

local ProfileStore = ProfileService.GetProfileStore(
	"Player",
	{
		coins = 0;
		gems = 0;
	}
)

Here’s the script where it errors:

local Players = game:GetService("Players")
local DataManager = require(game.ReplicatedStorage.DataManager)

while true do
	wait(10)
	for _, v in pairs(Players:GetChildren()) do
		local data = DataManager:Get(v)
		
		if data then
			data.coins += 25 --Error
			data.gems += 1
			
			print(v.Name .. " now has coins: " .. data.coins)
			print(v.Name .. " now has gems: " .. data.gems)
		else
			print("Does not have profile loaded.")
		end
	end
end

I’m trying to figure out ways on how to award the players from the ServerScript and I’ve been exhausting my options.

1 Like

What happens if you print Data.Coins? Is it nil?

At the first print it loads up a new error in the output:

[19:30:45.574 - ServerScriptService.Script:13: attempt to concatenate string with nil]

I’m not sure what I’m doing wrong here.

1 Like