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.