Hello,
So currently in my game, I am having loading time issues, I’ve noticed that the first time that a player joins, the loading screen loads in 0 seconds meaning it gets the players data in 0 seconds, but when they leave and join again, it takes 20 seconds and stays like that until you leave and wait a long time. Is this due to ProfileService taking a long time to release the profile? I’ve been trying to look into this for the past 3-4 days and I haven’t really found a lot. So I am just wondering how long it takes ProfileService to release a profile and if there is any way to make it faster.
This is my code to load and release a profile
local function PlayerAdded(player : Player)
ProfileStore:LoadProfileAsync(player, true):After(function(success, playerProfile)
if not success then
player:Kick(DataErrorMessage)
return
end
--/ Create leaderstats
playerProfile:CreateProfileLeaderstats(player, {"KOs", "Cash"})
local profile = playerProfile.Profile
local dummy = {
Data = {}
}
local callbacks = {}
--/ Value Changing
dummy.Data.__index = function(_,index)
return profile.Data[index]
end
dummy.__index = function(_,index)
if (index ~= "Data") then
return profile[index]
end
end
dummy.Data.__newindex = function(_,index,value)
profile.Data[index] = value
local callback = callbacks[index]
if not callback or typeof(callback) ~= "table" then return end
for _, callback in callback do
coroutine.wrap(callback)(value)
end
end
dummy.__newindex = function(_,index,value)
profile[index] = value
end
setmetatable(dummy.Data,dummy.Data)
setmetatable(dummy,dummy)
function dummy:OnDataValueChanged(index, callback)
if (not callbacks[index]) then
callbacks[index] = {}
end
table.insert(callbacks[index],callback)
local Connection = {}
function Connection:Disconnect()
table.remove(callbacks[index],table.find(callbacks[index],callback))
end
return Connection
end
--/ Global Keys
for _, globalKey in playerProfile:GetGlobalKeys() do
coroutine.wrap(HandleGlobalKey)(globalKey, profile)
end
playerProfile.GlobalKeyAdded:Connect(function(globalKey)
HandleGlobalKey(globalKey, profile)
end)
PSManager.Profiles[player] = dummy
end)
end
for _, player in srv.players:GetPlayers() do
coroutine.wrap(PlayerAdded)(player)
end
srv.players.PlayerAdded:Connect(PlayerAdded)
srv.players.PlayerRemoving:Connect(function(player : Player)
PSManager.Profiles[player] = nil
ProfileStore:UnclaimSessionLock(player)
end)
I am using EasyProfile for my ProfileService manager.
Any help will be appreciated!