Datasaving questions

I’m trying to make a datastore that isn’t already pre-made like ProfileService because it hasn’t worked for me in the past.

I had issues where if I wanted to delete a key in the dataTemplate, every player would still have the key saved.

If I want to change a value in a table, it may not update because of data regression and older versions overwriting the current version.

Is it supposed to be this way?

You’ll need to be specific here.

What’s datatemplate?

  • Is it some sort of template of data that every player will receive when they join?
  • Does every player get the template first, regardless of whether that player is new or not?
  • Is the template stored in datastores, or just within the servers?
  • Exactly how are you deleting a key within said template?

I might have a solution for you, but I need you to elaborate further before I share it.

ProfileService

I used this video the first time I used profileService and to initialize it I had to use the dataTemplate with had all the keys and values. I copied how he worded it.

Try suphies data store. I think it’s better you can see all the performance tests on the post, if you like I can link it.

Sure, I’m just trying to learn right now so things can work.

Which then begs the question - exactly what are you trying to do here?

  • If you’re using ProfileService, why are you saying you’re writing your own datastore code?
  • If you’re writing your own datastore logic, why are you copying a library whose internals you aren’t familiar with?

Anyways, I’ll address the pointers I raised up earlier in relation to ProfileService.

  • Is it some sort of template of data that every player will receive when they join?

When you initialize a new ProfileStore, you first have to define a template that every player will follow.

This is called a schema.

Anytime a new Profile is loaded in, ProfileService also checks the schema of that Profile against that template to see if they match.
If they don’t, ProfileService will try to match that Profile schema to the template’s.

This process is called reconcilation.

  • Does every player get the template first, regardless of whether that player is new or not?

As mentioned to point 1, reconcilation occurs anytime a Profile is loaded in, regardless of its data.

If I remember right, ProfileService will also do this as part of its autosave.

  • Is the template stored in datastores, or just within the servers?

Templates/schemas are always stored on serverside, not in datastores.

This also means templates are all the same across the server when they are first defined - unless, heavens forbid, you design it not to be this way.

  • Exactly how are you deleting a key within said template?

In extension to point 3, you can delete keys from the templates/schemas directly on serverside.

However, this won’t affect the schema that the player data already follows - you need to reconcile that player data again.


To be blunt, it sounds like you don’t really know what you’re doing here.

This should help shed some light, but please do some research by yourself so you don’t run into issues like these again.

Ok! Then here’s the link: Suphie’s dataStore Module

So I can’t just delete a key in the dataTemplate and it won’t destroy every player’s data? It seems more easy that way because I have to use WipeProfileAsync on every profile I messed up on.

thanks, its good he has video, I’ll check out.

No, it doesn’t work like that.
You’ll need to reconcile every player’s data with the template if you choose to edit the template schema in any way.

As I mentioned:

I used profile:Reconcile() when they join(from the video).

That leaves an edge case, where the template changes when the player is still in game.

Shouldn’t you also change the schema of the player data when that happens?

And actually - why are you even changing the template in the first place?

It sounds like you’re changing the template rather frequently, and I don’t understand why.

I was creating my first game that I was serious about. Doesn’t everyone change the dataTemplate over time?

During development, yes.
During runtime, no.

It’s very odd that you suddenly have to change your template while your game is still running.

Typically that’s only done during game updates (adding new content etc), or during development.

When that happens, you can shut down the entire game, so that every player that joins afterwards will have the same updated template.

ProfileService just wasn’t doing session locking like I expected it to. I also edited the keys and values in dataTemplate before the release in my game.