Save your player data with ProfileService! (DataStore Module)

Is the best way to use Profile:ListenToHopReady() when teleporting a group of users simply to wait until the callbacks for every user in the group has been called?

Yeah. When you release any amount of profiles at the same time, the maximum amount of time until all ListenToHop listeners are fired is around 7 seconds.

1 Like

Hi there, I’m a relatively new scripter & I’m looking into using ProfileService. I’m having an issue where it says my data has corrupted.
Error: ServerScriptService.ProfileService:1914: ServerScriptService.ProfileService:806: [ProfileService]: PROFILE DATA CORRUPTED DURING RUNTIME!
Code:

local profile = LobbyProfileStore:LoadProfileAsync(
“Lobby_” … LobbyId,
“ForceLoad”
)
if profile ~= nil then
profile:Reconcile()
profile.Data = game:GetService(“HttpService”):JSONEncode(data)
profile:Release()
else
print(‘[DatastoreHandler] - Fetch data failed.’)
end

What I am trying to do is update the data for that datastore, I have even tried to make profile.Data = “test” which still says it corrupts, I’m quite confused and would appreciate any assistance on fixing the issue.
Thanks in advance!

profile.Data can only be set to a table so setting it to a string will throw errors.

Hey, thank you for your reply. Is there a way to store dictionaries in profile.Data?

Hi, is there any (easier) alternative to this?
I already have my own version which saves data on first purchase and then queues next purchases and after repeating wait(1) until a 30 second cooldown runs out, it saves again. I don’t know how reliable this is though.

As I understand, the function in your post is supposed to repeat every second until the purchase is saved?

The function I posted for developer product handling is supposed to delay the process receipt callback confirmation return until we’re sure ProfileService has auto-saved (or manual saved) the purchase. Since ProfileService is built around UpdateAsync, every DataStore save is also a DataStore get - we can check what has been saved to the DataStore. ProfileService only exposes MetaTagsLatest part of the DataStore get which my function used to determine if an associated purchase id is guaranteed to be saved.

Hello there. I just recently started using ProfileService and may I just say I really like what I’ve seen so far! I do have a couple of questions though.
Is there a way to alter the data that gets saved?
Meaning, say I have the playerdata (profile.Data) what it is, load it up and put random (temp) values within the playerdata itself that I do not want saved. Is there a way remove the temp data from the playerdata table itself before it saves, or should I go another route?

Thanks – IDKBlox

this module is amazing. I just have 1 question. Is there any way to import data into it? We are currently revamping an older game and we want to preserve the data from it(1 value in leaderstats) and I am hoping there is a way to import that data somehow so that we don’t have to do it by hand.

check out ProfileStore.Mock it’s made for testing stuff you don’t want to save

Okay. Is there an event that fires when data is (auto) saved or any other way without having to have a loop?

Thanks for the response, but you seemed to have misunderstood what I was asking.
I’m wanting to use the data within a live server. I just do not need it to save lol. (Aka, something like PlayerData.Base = Workspace.Bases.IDKBlox ) – Which obviously could not be saved in datastore because it’s an instance. Therefor, I’d like to removed it from “PlayerData” before it saves.

A dictionary is a table, which means that it can be saved so long as it’s setup in a way where its data can be serialized. This is briefly covered in ProfileService’s Troubleshooting page.

This is actually pretty discussed at the GitHub sometimes, but:

Nope. I’m pretty sure loleris is not as cool with that idea as of now.

Though, I don’t think it would be that hard to make a signal which you can use, by forking it, I woudn’t fork it personally, as you woudn’t be able to update easily.

Update: made a feature request for a signal which fires AFTER a profile was saved, i don’t have high hopes but let’s see I guess.


@IDKBlox as of now, what you said is not possible. I would recommend looking for another way. That’s essentially what I talked about above.


we did it boys :sunglasses:

1 Like

well as far as i understood the creator of the module, mock can be used in live servers without issue for that very purpose, perhaps you should ask him directly or ask someone who has more experience with this module

I suggest packing Profile.Data as a member of another table:

local player_data = {
   Save = Profile.Data,
   Session = {
      YourTemporaryData = 1,
   }
}
-- This way you create a single variable containing both savable and temporary data

In case you didn’t know, tables are assigned to variables as references and assigning other variables to your table will only clone the reference, but all variables with that reference will point to the same, uncloned, table.

local t = {}
local t_ref = t -- This will not deep-copy a table;

t_ref.Value = 1 -- "t_ref" and "t" point to the same exact table
print(t.Value) --> 1

Lua documentation:
https://www.lua.org/pil/2.5.html

3 Likes

Ok, I’m confused, would this work for money system and such, on a per player basis? @loleris

For the most part, profile service is for player data. Yes.

Using ProfileService just means that your data is like 99.999% guaruanteed to be saved before it is ever loaded.

ProfileService for the most part, is not for other types of data. It’s mostly for player data.

[04/30/2021] Cumulative update including new member Profile.MetaTagsUpdated

Github commit fdb8d7e

New Profile class member - Profile.MetaTagsUpdated

There were several silent updates since the last announcement like automatically throttled Profile:Save() calls which now make Profile:Save() completely safe to use.

Array type script signals have been replaced with linked list type script signals which will have more predictable :Disconnect() behaviour in complex implementations.

And finally - I whipped up a whole functional example code for handling developer products with ProfileService. Go read it and melt your brains.

You may update the module through github or the Roblox library.

6 Likes

Are there any plans to separate ProfileService into multiple sub-modules for easier managament of stuff like Signal APIs? Why specifically did you go with packing everything into one module?