Haha, so sorry it was a mistake on my end! I used ProfileStore
when it’s actually the module
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.
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.
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
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
Also impressive to see the difference in lines with the previous module! And thank you so much for the types you’re a lifesaver.
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.
This part of the script acts perfectly fine (Manager is a child modulescript), and successfully displays all the data (output shown below)
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.
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.
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.
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.
Would you ever consider doing a similar data store module that isn’t session locked? There’s certain uses cases that I don’t want session locked by a player and instead use a global key that I want any player to access at anytime
Why not just use normal datastores at that point?
That sort of system wouldn’t be scalable, or in other words, you’d be fine with writing to one key when your game is at less than 100 players, but when 1000+ players play your game accessing one DataStore key more and more will make the system halt as Roblox DataStores were not designed for this and have a limit on how many times you can write to a single key until you run into serious issues.
The module you speak of could not exist, at least it would not work like ProfileStore.
I only ask cause I stumbled into this the other day
which caters to both forms of data
Modules can’t change the fact that DataStore keys have a limit on how often you can write to them from different servers at the same time which makes implementations where you’d have something changeable from all servers non-scalable.
Some limitations can be found here:
Data storage is not magic and there’s a limit to everything, so not everything is possible, but there’s usually a workaround for certain features you want to create.
Currently trying to implement a ‘ban wave’ system. Issue is that when a ban wave occurs, all the players caught in the ban wave aren’t necessarily online or may be in another server (their data is session-locked). Is it possible to load a player’s data who happens to be offline and force write to a certain key (in my case, a “banned” key) even though their data may be session-locked?
You would use MessageAsync for this
https://madstudioroblox.github.io/ProfileStore/api/#messageasync