Save your player data with ProfileService! (DataStore Module)

So im currently trying to use the DataStore Editor 3.0 plugin made by @sleitnick to change a player’s data and have so far gathered this.


Im not sure if i should include the scope or not and am stuck on what the key is to be.

image

If you choose to respond thank you for helping! :+1:

You are using OrderedDataStore option just turn it off.

1 Like

I noticed when I set a metatable on the profile object, Some functions somehow turn into nil, Is this because of the module, or is it because of Roblox?

1 Like

so then do you just use the player’s userid as the key?

1 Like

Well I don’t really know how you set up your profile’s key. You can check it by doing profile:Identify() and see what the key is.

2 Likes

Hi All,

I have a custom data module that sits on DataStore2. Aside from loading it only interacts with datastore2 in one function:
image

I was hoping to only swap this function out but I’m not sure how to directly set a player’s full profile directly. My handler deals with all data manipulation internally so I’d like to avoid having to swap out all the functions.
For context my primary interest in PS is session locking for trading.

Is this possible?

Thanks!

I really like this Datastore, it’s simply to use and easy to understand. The only question I have is, I see you have an autosave feature and you replied to another user that this doesn’t work with ordereddatastores, do you mean it’s not save to call GetOrderedDataStore() even if its outside the profileservice? If so, can I do things to make it so it is safe, as in reduce the amount of autosaving profileservice does?

Edit: Apologies I realized this has been asked many times before, carry on.

1 Like

Say no more! Although other people made tutorials on how to use it, they never really use ReplicaService to present their data to the client’s screen, fear no more because I just created a new topic on how to use both ProfileService and ReplicaService together! Please check it out!

3 Likes

Is there a way to get all profiles ever made without access to the keys? I want to get the profile of every player that ever joined the server so I can transfer their data. Is there a way to do this? Or no option but to let the data be wiped?

Hey @loleris thanks for sharing this, saving me a lot of time. Your docs are next-level.

Will construct a small shrine of you in my next game. Do you prefer gold or blackiron?

Your friend/fanboi,
John

28 Likes

I don’t understand "
– ProfileTemplate table is what empty profiles will default to.
– Updating the template will not include missing template values
– in existing player profiles!"

I also don’t understand the profiles at all (especially in Developer Products - ProfileService)

1 Like

It’s basically a dictionary acting as the default data that’s going to load for a new profile in a ProfileDataStore.

This just means if you update the template, it will not include the keys that doesn’t have a value.

Profiles are just basically something that represents a player’s data.

Seeing as MemoryStore was just released, is there anything that you might do to accommodate MemoryStore? It would be nice to have some new specific APIs for ProfileService that will reliably work with MemoryStore seamlessly.

I haven’t really looked too deeply in MemoryStore but I can imagine some devs (such as myself) will work the service with it and may end up making mistakes that will break ProfileService.

6 Likes

ProfileService functionality remains the same - ProfileService is based around permanent and server-locked read-write behavior and that’s the sole purpose of why anyone uses ProfileService in the first place.

Obviously MemoryStore can be used in conjunction with ProfileService, but MemoryStore is no longer any of ProfileService’s business.

ProfileService primarily addresses the serious lack of session locking and periodic saving support in first-party Roblox DataStore APIs - session locking and periodic saving is universally needed among many Roblox games and people keep rewriting the same boring code that handles those things instead of just using a Roblox provided API for session locking and periodic saving.

8 Likes

For developer products page, it shows ```
ProfileTemplate = {
Cash = 0,
},


do I have to include the same template? Or just the values I want to change?

I don't want to spend a while looking at the source code to see how it works

You can include the same values which are the values you used for your current DataStore. The table you used won’t overwrite any existing data inside your DataStore, however if the requested key is nil inside the DataStore, this is where the template comes in.

So, I don’t have to include all of them?

You still have to, for example let’s assume your current DataStore system’s template is like this:

local template = {
    Cash = 100,
    Wins = 0
}

By default, you would do an if statement to check if the player has existing data or not, or in simple terms, if they are a new player. If they are a new player, then you would use this template and use your own logic to present the data, if they aren’t a new player, you would just get the key-values retrieved from DataStoreService:GetAsync().

If you use ProfileService, its backend will handle this situation, so you don’t have to worry about if the player is new or whatsoever because ProfileService will still handle this.

The template which is in the code above needs to be the same as your current data store for ProfileService, because imagine where you just only add Cash and not Wins, ProfileStore will ignore the key-value pairs of Wins, resulting you would only get Cash.

If it ignores it, then certain places that don’t need to access certain values (such as purchase handlers) then I can choose not to include certain items?

Hey,

I already tried ProfileService before, and it’s great…

But I can’t seem to save the data now (I know it saves automatically)

Any ideas why?