ProfileStore - Save your player data easy (DataStore Module)

Haha, so sorry it was a mistake on my end! I used ProfileStore when it’s actually the module :joy:
Instead it should be PlayerStore lol. Honestly, so far it’s going great. Even when DataStore isn’t available, it still works like a charm. So far I’m pretty fond of the new module. And hey, saving is much faster than before which is exactly what I want. Hoping you’ll impress with the new “Replica” module that’s coming its way!

I appreciate Replica is going to be released any day now, but in the meantime is ProfileStore backwards compatible with ReplicaService? Looking to replace my half-finished ProfileService implementation in a new project but today’s the only chance I’ll get to work on it until next week.

Hey there. My game uses ReplicaService for client-server communication and I’ll say this. ProfileStore does work with it since it has a table profile.Data containing the user’s data. It’s exactly the same as before with using ProfileService except this one is much better and less messy. It also uses proper and up to date method such as string interpolation and offers cleaner code. Anyway, not sure what you mean by backwards compatibility but I’ve tried using the current ReplicaService with the new ProfileStore module and it seems to be working fine.

1 Like

is there a way to modify the player data when they are offline through using this?
Use case is making a player owned marketplace so when player 1 buys an item from player 2 and that player 2 is offline, i need to update the player 2 money for profits.

1 Like

1 Like

I just read through that, thanks.

I was wondering if there was any update on this? I am about to start a new project and would love to include the latest Replica version to avoid having to switch halfway through

1 Like

Thank you, @loleris, your work is always appreciated.

I have already switched from ProfileService to ProfileStore, changed 1 variable name, couple of methods names, and everything already works like a charm, it’s quite magical honestly. I appreciate the work, the effort, and the care you put into helping other users in the community :pray:

Also impressive to see the difference in lines with the previous module! And thank you so much for the types :sob: you’re a lifesaver.

2 Likes

Sorry if this is a stupid question since I’m not too experienced; but I’m having some trouble accessing the datastore on a different modulescript.

image
This part of the script acts perfectly fine (Manager is a child modulescript), and successfully displays all the data (output shown below)
image

However, trying to access this data from “Manager” (the modulescript), will always throw a nil. Here, player data will always return nothing, even if I printed I; It seems as if module.Profiles does not exist here, so it simply returns end and stops the script. Is there anything I’m missing here?

TLDR: Profile table works in one script, but doesn’t in the modulescript.
image

Are you sure that both of them run in the server and the player argument is proper? Your explanation is quite confusing

Sorry; I just mean that in the 1st script, I can successfully get the profile of the character, but said profile shows up as nil in the child modulescript (That’s parented to the first script) even when said modulescript is referred to.

Both scripts are server-side only

This is most likely because ProfileStore doesn’t yield, and when you call the function addItem it would obviously return nil as there is no index within the module.Profiles table following the Player object. Now as for fixing this, I recommend making a module that would return a signal indicating that the player’s data is loaded and THEN call the function or simply do a repeat until scenario in the module over returning which I don’t think that’s a good method.


Me personally? I have an OOP module called PlayerDataService which pretty much handles the player data loading part — passed the Player object as argument.



However in this case, I’m also using ReplicaService of which I return that instead.


image
Then, I would simply call the Load method and listen for the OnLoad custom signal which returns the Profile object that allows me to work my way through.

image
And alas, I store both Replica and Profile separately within my custom Player object implementation. I did this so I could easily access it anywhere at anytime on server scripts.


If you think that this approach is way too tedious, then it’s fine. Just know that I believe the reason why it returns nil is because it couldn’t find anything within the module.Profiles table of the Player object index. If you tried printing the table then it would return an empty table {} which I can guarantee you. So either you’re calling the addItem function way too early before the player’s data was even able to load in, or I’m just completely off the track. Anyway, hope this helps somehow.

Unfortunately I don’t think this can really work in this contexts. The specific “Additem” I’m firing right now to test… only fires when the player kills an mob in game by dealing enough damage to it (which a script fires additem to add a item to the player), so the data by then has most definitely loaded in.