(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!
(This is kinda hindering the progress of my game, so really, any feedback or help would help me so much)
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.
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!
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.
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.