So I’ve been trying to fix this issue for a while and still cannot find a clear solution to this. Upon joining my game, ProfileService kicks me because I do not have a loaded profile. I don’t know why this is happening. It works some of the times and the other times it doesn’t. Here is my OnPlayerAdded script.
local ProfileService = require(game.ServerScriptService.ProfileService)
local Players = game:GetService("Players")
local ProfileStore = ProfileService.GetProfileStore(
"ProfileDataTEST5",
ProfileTemplate
)
local Profiles = {}
local function PlayerAdded(player)
local profile = ProfileStore:LoadProfileAsync("Player_" .. player.UserId,"ForceLoad")
if profile ~= nil then
profile:AddUserId(player.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
Profiles[player] = nil
player:Kick("ListenToRelease Fired")
end)
if player:IsDescendantOf(Players) == true then
Profiles[player] = profile
else
profile:Release()
end
else
player:Kick("Could not find data")
end
end
The service is unreliable, especially when testing. Do not kick players if the data can’t be loaded. Handle the error correctly. The service also replies with data telling you if you are being rate limited.
I assume it does the kick “Could not find data”?
You can try not using “ForceLoad”. The default should work fine in most cases (remove the second argument).
It’s literally the default code from ProfileService which has been battle tested in many games. (despite what the docs say)
ProfileService already handles it for you. Since OP is “force-loading” the data, the profile will retry loading until it actually loads, and if the retry count exceeds a certain value (8), it will steal the data from another session (since profile service also handles session locking; the above case might happen when a user logs into the same game again before the data has been saved) and the profile will only be nil in rare cases such as when the roblox datastores decideds to be wonky or smth else, in which case there is really no other option other than to kick the player.