Mutliple .GetProfileStores?

Hello!
What I am trying to achieve is quite simple. My game provides multiple character slots for the player to use and you are able to save data with each slot. (Slot 1 has level 2, slot 2 has level 9, etc.)

However, to save data in my game I am using ProfileService. To get a player’s data, you need to use .GetProfileStore(“DataNameHere”). In order to save multiple slots, I can’t have slot 2 save as slot 1’s data, so my question is - “Can I use multiple .GetProfileStores?”.

This is an example of what I mean:

local ProfileStore = ProfileService.GetProfileStore("Slot1", saveStructure) -- Standard slot1,
local ProfileStore2 = ProfileService.GetProfileStore("Slot2", saveStructure) -- slot2,
local ProfileStore3 = ProfileService.GetProfileStore("Slot3", saveStructure) --slot3,

And if that works, should I change the code where it gets your data? e.g.

	local profile = ProfileStore:LoadProfileAsync( -- Loading the 1st profile
		"Slot1User_"..player.UserId,
		"ForceLoad"
	)

	local profile2 = ProfileStore:LoadProfileAsync( -- Loading 2nd profile
		"Slot2User_"..player.UserId,
		"ForceLoad"
	)
	
	local profile3 = ProfileStore:LoadProfileAsync( -- Loading 3rd profile
		"Slot3User_"..player.UserId,
		"ForceLoad"
	)

	if profile and profile2 and profile3 then -- If all profiles exist
		profile:ListenToRelease(function()
			cachedProfiles[player] = nil
			player:Kick("Unable to load data. Please rejoin.")
		end)
		profile2:ListenToRelease(function()
			cachedProfiles2[player] = nil
			player:Kick("Unable to load data. Please rejoin.")
		end)
		profile3:ListenToRelease(function()
			cachedProfiles3[player] = nil
			player:Kick("Unable to load data. Please rejoin.")
		end)
		
		if player:IsDescendantOf(Players) then
			cachedProfiles[player] = profile
			cachedProfiles2[player] = profile2
			cachedProfiles3[player] = profile3 -- Storing the data
			PlayerDataLoaded(player)
		else
			profile:Release() -- Release all profiles (session locking)
			profile2:Release()
			profile3:Release()
		end
	else
		player:Kick("Unable to load data. Please rejoin.")
	end

Would all this work? Or is a tedious method that could be changed?
Any help would be appreciated!

3 Likes

Did you found another method for that?

were you able to find a more efficient way?

For anyone looking for future references just store your slots in one key, each key has up to 4mb and even if you do space it out between different keys your game is only given an additional 1mb per unique visit so if you do manage to use 4mb on each key your gonna run out of space really quick.

1 Like