Correct, if you want to pass through CurrentSlot as a parameter you can but i would just load the currentSlot in Manager.GetCurrentSlot()
. But then again its your preference. I would do it my way because you want to load the slot that the ProfileStore has saved, this way when you go to save the players data in case any error it doesn’t overwrite a slot.
But yeah if you would like to provide an example of what you mean you can!
Example:
local function GiveLeaderstats(player: Player)
local profile = Manager.Profiles[player]
if not profile then return end
local profileData = profile.Data
-- Add folders to player and whatnot
end
local function PlayerAdded(player: Player)
local profile = ProfileStore:LoadProfileAsync("Player0_"..player.UserId)
if profile == nil then
player:Kick("Saving failed. Please Rejoin!")
return
end
profile:AddUserId(player.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
Manager.Profiles[player] = nil
player:Kick("Saving failed. Please Rejoin!")
end)
if player:IsDescendantOf(Players) == true then
Manager.Profiles[player] = profile
GiveLeaderstats(player)
local globalUpdates = profile.GlobalUpdates
for index, update in pairs(globalUpdates:GetActiveUpdates()) do
globalUpdates:LockActiveUpdate(update[1])
end
for index, update in pairs(globalUpdates:GetLockedUpdates()) do
handleLockedUpdate(globalUpdates, update, profile, player)
end
globalUpdates:ListenToNewActiveUpdate(function(id, data)
globalUpdates:LockActiveUpdate(id)
end)
globalUpdates:ListenToNewLockedUpdate(function(id, data)
handleLockedUpdate(globalUpdates, {id, data}, profile, player)
end)
else
profile:Release()
end
end
for _, player in ipairs(Players:GetPlayers()) do
task.spawn(PlayerAdded, player)
end
Players.PlayerAdded:Connect(PlayerAdded)
Players.PlayerRemoving:Connect(function(player: Player)
local profile = Manager.Profiles[player]
if not profile then return end
profile:Release()
end)
It is worth mentioning that I am trying to migrate this to ProfileStore at the same time while making this multi-slot save data. However, this example is still ProfileService.
You should switch to ProfileStore, first before you continue the switch is REALLY easily, i done it with my game and it was flawless. But basically you need to do if the player is a descendant of players
then add your Manager.SetCurrentSlot(player, 1)
. Its hard coded for now until you add user input. Then you do Manager.LoadCurrentSlot(player)
. And then it would load whatever the current slot is
do you have an example of what a manager script would look like that works for ProfileStore? I am trying to use the manager script from ProfileService but I can’t tell if its recognizing it or not.
The manager script should be the same, the only thing that changes when you go from ProfileService → ProfileStore is where you load the player data. loleris put a good in depth documentation, you could try and look there.
I am trying to run the GetCurrentSlot manager function from the data script, but it does not seem to be working as the print in the manager is not showing.
Is there a CurrentSlot
value in your template? If so this is how you would reference it. In this ORDER
Manager.SetCurrentSlot(player, 1)
local currentSlot = Manager.GetCurrentSlot(player)
print(currentSlot) -- SHOULD print 1
Manager.LoadCurrentSlot(player) -- Loads Slot 1