#ProfileService taking too long to load data.

1 messages · Page 1 of 1 (latest)

vocal urchin
#

Simple script that just updates the UI (based on player's data), Returning nil cause data taking too long to load, I've been trying to add task.wait and everything, The only thing that works is like a 20 second wait...Which probbably isn't ideal.

#
function DataServiceServer.Init(self: DataServiceServer,dataKey,dataTemplate)

    ProfileStore = ProfileService.GetProfileStore(dataKey, dataTemplate)

    self.networker = Networker.server.new("DataService",self, {
        self.Get
    })

    for _, player in Players:GetPlayers() do
        task.spawn(DataServiceServer.Load, player)
    end

    Players.PlayerAdded:Connect(DataServiceServer.Load)

    Players.PlayerRemoving:Connect(function(player)
        if Profiles[player] then
            Profiles[player]:Release()
        end
    end)

    print(script.Name .. " Init")
end

function DataServiceServer.Load(Player: Player)
    local profile = ProfileStore:LoadProfileAsync("Player_" .. Player.UserId)

    if not profile then
        Player:Kick("Data error, Please rejoin")
        return
    end

    profile:AddUserId(Player.UserId)
    profile:Reconcile()

    profile:ListenToRelease(function()
        Profiles[Player] = nil
        if Player then
            Player:Kick("Data error, Please rejoin")
        end
    end)

    if not Player:IsDescendantOf(Players) then
        return profile:Release()
    end

    Profiles[Player] = profile

    local success, err = pcall(function()
        leaderstats:Create(Player, profile)
    end)

    if not success then
        warn("Leaderstats Error:", err)
        profile:Release()
        Player:Kick("Stats error, please rejoin")
    end
end

gleaming ermine
harsh lagoon
#

isnt profilestore better?

vocal urchin
rose kindle
#

Update everytime the Profile gets updated?

flint valley
#

bro wyd

#

just copy the code from the github