I have this profile service handler it works fine with saving the data when the player joins a server for the first time but if the player rejoins it yields an error that the player is already loaded but I can’t access the data, how can I get the data if the player is already loaded in profile service?
local function OnPlayerAdded(player)
print("Player Added")
print(Manager.Profiles[player])
Manager:LoadProfile(player)
Tool_Handler.LoadTools(player,Manager.Profiles[player].Data.Owns)
end
And the manger
function Manager:LoadProfile(player)
local profile = ProfileStore:LoadProfileAsync("Player_" .. player.UserId)
if profile ~= nil then
profile:AddUserId(player.UserId) -- GDPR compliance
profile:Reconcile() -- Fill in missing variables from ProfileTemplate (optional)
profile:ListenToRelease(function()
Manager.Profiles[player] = nil
-- The profile could've been loaded on another Roblox server:
player:Kick()
end)
if player:IsDescendantOf(Players) == true then
Manager.Profiles[player] = profile
-- A profile has been successfully loaded:
OnProfileLoaded(player, profile)
else
-- Player left before the profile loaded:
profile:Release()
end
else
-- The profile couldn't be loaded possibly due to other
-- Roblox servers trying to load this profile at the same time:
player:Kick()
end
end
``` it's pretty much the same as the one mentioned in wiki