How should I use & access save information using ProfileService?

:wave: Hello developers!

(SOLVED - CHECK THIS COMMENT FOR A FULL EXPLANATION)

I’m making a game that requires information to be saved & accessed frequently. I’m using ProfileService. So far I’ve gotten information saving, however, I’m not exactly sure how I should access it. The information will have to be accessed via a different script than the one saving it.

I heard you can use a ModuleScript, however, since ProfileService runs on the server, wouldn’t that information be constantly overwritten by a different player?

How should I go about this? Any feedback would be greatly appreciated! :slightly_smiling_face:
(This is kinda hindering the progress of my game, so really, any feedback or help would help me so much)

1 Like

OK, so if you are using this Save your player data with ProfileService! (DataStore Module) - Resources / Community Resources - DevForum | Roblox, then I used the following resources to help me understand the how:
Intro to ProfileService
ProfileService: EncodedLua

1 Like

Finally… I thought of a way to do this! :grinning_face_with_smiling_eyes:

I have 2 BindableEvents in a folder named Remotes in ReplicatedStorage: ReqSaveInfo and SaveInfo. ReqSaveInfo is meant to be fired when saved info is needed and SaveInfo is fired just after. SaveInfo returns the data that needs to be accessed.

This is safe from exploiters as the BindableEvents are fired exclusively from Server <—> Server meaning nobody can intervene them using LocalScripts.

In the script that handles the Save Data, I put this snippet in after everything in if profile ~= nil then:

Remotes.ReqSaveInfo.Event:Connect(function(Player, DataAccess)
	if Player == player then
		Remotes.SaveInfo:Fire(player, profile.Data.Character)
	end
end)

Then, when I need the info from a separate script, I will use this:

Remotes.ReqSaveInfo:Fire('plr', 'info to gather') -- Replace 'plr' with actual Player instance

Remotes.SaveInfo.Event:Connect(function(Player, Feedback)
	if Player == 'plr' then -- Replace 'plr' with actual Player instance
		print("Feedback: "..tostring(Feedback))
	end
end)

I can’t believe I didn’t think of this sooner.
Hopefully this helps someone out in the future! :slightly_smiling_face:

PS. apologies for the lack of a reply @BadDad2004!

I didn’t really utilize these video tutorials as they often feel very inefficient, whereas reading and/or problem-solving is dozens faster.

tl;dr I’m lazy

1 Like

I prefer reading as well, but these were actually useful for a change, when I couldn’t find any real world examples of using ProfileService for data storage. Glad to hear you got it sorted tho.

2 Likes