I have been using profile store for a couple of days but im building a system which needs to access the player’s data on the client. Do i have to create a new script to load the player’s data on the client or just require it through my data manager on the server?
Your client won’t see the data that is stored in the module script that was required by a server script. So you need some system that will send the data to the client via Remote Event.
Ok thanks gojo, would it be like a module which loads all the data using a remote function then the client can use a function in the module which returns the data they request?
Yeah that could work. You can also make it so that the server notifies the client when something changes.
You can either do what Arkston has suggested, or opt in for using Replica which is made by the same developer
As others suggested, you can use Replica. But I made my own replication system instead since I didn’t know it existed some time ago. It goes like this:
- Server does normal ProfileStore stuff
- Client joins, fires a RemoteFunction (or RemoteEvent for async) to get their data from the server.
- Client stores that data in a ModuleScript for other client scripts to access.
- When the server updates data, simply fire to the player to update the data in their ModuleScript.
Minimal changes to the server. Just a RemoteFunction listener and RemoteEvent fire in your update() function. I assume Replica works similarly.
Caveats: The client side is basically a lighter version of the server, so you have to make get() and subscribe() functions there too. Also, you gotta manage race conditions from other scripts trying to get the data when the client hasn’t set it yet (Use promises, signals, or just while wait()).
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.