Save your player data with ProfileService! (DataStore Module)

This has become my preferred Player Data library on my last few projects, amazing work!

I was curious if there has ever been the idea of handling unsupported Data Types for Data Stores? What I mean by this is that since things like Enums or Vector3s are unable to be directly stored in a Data Store without manually serializing them, why not do that automatically in the library?

My idea for implementing this is as follows (we’ll use Vector3 as an example):

  • Upon saving data check if the data is an unsupported type
  • If data is a Vector3 (5, -1.75, 10) then serialize it to a table {type = "Vector3", value = "5, -1.75, 10"}
  • Upon getting data check if data is a table and has type property. If it does convert it back to its original object

There are likely better ways of creating this system, but it’s just a quick idea to hopefully paint the picture.

If you’re not against adding this feature, I’d even be fine implementing it myself and submitting a pull request, if you wouldn’t want to do it yourself!

3 Likes

Has anyone rewritten ProfileService to be shorter? I want to write my own session locking data specifically for my game and I feel like 2,000 lines can be condensed into something I can understand. :sweat_smile:

1 Like

You should make your own then, don’t ask others to make it for you. Learn from what this module does for session locking and make one of your own.

1 Like

I didn’t ask for someone to do it for me, I asked if anyone has done it. It’ll save me a lot of trouble if someone tells me they’ve tried and it’s not possible versus me spending half a day trying to rewrite it to my understanding.

Even if I was asking for someones copy of a condensed ProfileService module, or for someone to do it for me, there was no need for your reply. No one is being forced into doing anything.

1 Like

Solved Not Sure How But All Working Fine Now!

Would anyone know why my player data does not save no matter what I do.

I have got all API services on and needed things and have tried in game and not studios there is no errors and I am checking if profile release is done when leave and it is been done but the data is not saving at all.

Can I see how you would do this? I’d like to use this with Firebase (because my game spans multiple different games and DataStore doesn’t work for it)

how would I update a player’s data using plr:GetJoinData()?

I’m making a tower defense game, and I want to award the players some cash if they win, but if they leave the server instead of clicking the button to leave, what i think would happen is that the player will not get the cash he would receive.

Is it possible to update a player’s gold data in a place where ProfileService module is not present? and it gets updated by just doing this?

local prize = 400
game.Players.PlayerRemoving:Connect(function(plr)
    local data = plr:GetJoinData() -- ??
    local cash = data.TeleportData.Data.Cash
    cash += prize
    
    data.TeleportData:Release() -- ????
end)

Hi loleris,thank you for providing such a great datastore module to the community :+1:
I have a question. The following is part of the code of the CustomWriteQueueAsync function


why is it not added to the queue at all or removed from the queue before the callback is called? When there are multiple update requests in the queue, if some callbacks take a long time to execute, multiple UpdataAsync operations will be executed at the same time. Is it designed this way because there is a low probability of this happening with a 7 second write interval?

In addition, if the above code is changed to the following, will it bring other problems?


My understanding of ProfileService is still superficial, I hope to get your reply

Sorry, I have found that this modification is incorrect :smile:

Actually the queue is also necessary because Roblox does not guarantee parallel UpdateAsync calls being finished in the order they were called

1 Like

Yes, the queue is necessary. The problem with my modification above is when the last UpdateAsync is executing, calling Profile:Save() will not call SaveProfileAsync because #queue > 0, resulting in the latest Profile may not be saved in the DataStore.

Hello
Is there a place (event) in the ProfileService, where I can put my code which collects data from the workspace, converts it to a suitable format and puts it in the profile.Data object?
I.e. I need to populate the profile.Data with the correct data, each time before the profile is saved.
I see in the basic example that 1 such place is the PlayerRemoving handler, where profile:Release is called. But for sure there are other places - when the server is shutdown or when auto-save is invoked, etc.
What would be the most correct approach?

Thanks in advance

Amazing work. This is a life saver.

One question :

How is it possible to use ZonePlus and make a zone, that gives 2x or 3x the amount of Time when inside of it. Im curious how I can increment the store by double or trip the amount.

1 Like

Quick Question regarding ForceLoad; If I make every server that starts up force load a single profile, which I understand makes it so that only the first server has the profile loaded. If the server that has the profile loaded closes and the profile is released, would one of the other servers that ran force load catch it at random?

Hi, I have a question; if a server loads a profile and then shuts down is that profile automatically released, or should I call profile:Release() in the context of BindToClose?

I’m using/creating profiles that correspond to the server itself rather than individual players, so my system loads the profile as soon as the game starts, and I just need to release the profile as soon as the server ends. My eventual goal is to store the JobId of the server currently loading the profile in the profile itself, and then in any other server that tries to load the same profile, it fails and instead gets the JobId of the server that has locked the profile using ViewProfileAsync(), and teleports the player to that server. Hope that makes sense.

Thanks for your great work

Yeah ProfileService will manually release all profiles on server shutdown

2 Likes

Do you have any idea why this error keeps popping up?
image

Does it result in a loss of player data?

Profileservice lacks the most substantial function of detecting changes in player data, how funny can this be?

Are you changing it from in the script or are you adding the values in-game?

So are you releasing the profile when player has left the game?