This happens to a small subset of players in my games that use ProfileService. I have not been able to find other threads (not made by me) that discuss this issue + how to resolve it.
Associated codes at lines mentioned:
--- player data handler module
function PlayerDataHandler:playerAdded(player)
local profile = ProfileStore:LoadProfileAsync("Player_"..player.UserId)
if profile then
profile:AddUserId(player.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
Profiles[player] = nil
player:Kick("To protect your data, you were kicked from the game.")
end)
if not player:IsDescendantOf(Players) then
profile:Release()
else
Profiles[player] = profile
player:SetAttribute("init",true)
end
else
player:Kick("There was an error loading your data, and for your protection, you were kicked from the game. Please try again!")
--logger.dataFail(player,"Data did not load correctly upon joining")
end
end
---ProfileService script
-- Check if profile with profile_key isn't already loaded in this session:
for _, profile_store in ipairs(ActiveProfileStores) do
if profile_store._profile_store_lookup == self._profile_store_lookup then
local loaded_profiles = is_user_mock == true and profile_store._mock_loaded_profiles or profile_store._loaded_profiles
if loaded_profiles[profile_key] ~= nil then
error("[ProfileService]: Profile " .. IdentifyProfile(self._profile_store_name, self._profile_store_scope, profile_key) .. " is already loaded in this session")
-- Are you using Profile:Release() properly?
end
end
end
Guessing …
Attempting not to load the same profile multiple times.
-- player data handler module
function PlayerDataHandler:playerAdded(player)
local profile = ProfileStore:LoadProfileAsync("Player_"..player.UserId)
if profile then
profile:AddUserId(player.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
Profiles[player] = nil
player:Kick("To protect your data, you were kicked from the game.")
end)
if not player:IsDescendantOf(Players) then
profile:Release()
else
Profiles[player] = profile
player:SetAttribute("init",true)
end
else
player:Kick("There was an error loading your data, and for your protection, you were kicked from the game. Please try again!")
--logger.dataFail(player,"Data did not load correctly upon joining")
end
end
-- ProfileService script
-- Check if profile with profile_key isn't already loaded in this session:
for _, profile_store in ipairs(ActiveProfileStores) do
if profile_store._profile_store_lookup == self._profile_store_lookup then
local loaded_profiles = is_user_mock == true and profile_store._mock_loaded_profiles or profile_store._loaded_profiles
if loaded_profiles[profile_key] ~= nil then
warn("[ProfileService]: Profile " .. IdentifyProfile(self._profile_store_name, self._profile_store_scope, profile_key) .. " is already loaded in this session")
return -- or do something else to handle this case
end
end
end
if loaded_profiles[profile_key] ~= nil then
warn("[ProfileService]: Profile " .. IdentifyProfile(self._profile_store_name, self._profile_store_scope, profile_key) .. " is already loaded in this session")
return -- or do something else to handle this case
end
try not to load the same profile multiple times (if you are doing this), maybe this is causing the error or it is probably just an internal ProfileService error
What kicking them? I was hoping that post was it to avoid that.
I have a game that puts on a custom outfit on logging in, if it doesn’t work out they get kicked. Sad fix, but it works.
No, I mean is there a way to avoid the issue of the Profiles not loading happening? I’ve calculated that at worst, it happens <1% of the time, but it’s still an issue.
Whenever a player leaves the game, you MUST release their profile immediately - there can be no ands ifs or buts about that. I found that some players, when attempting to join the game, would repeatedly be joined in and then booted out a few times over due to their connection and how ROBLOX works (I think) so if the release statement isn’t unabated it would cause issue.