#Im crashing out with dataStores please Help me

1 messages · Page 1 of 1 (latest)

atomic turtle
#

In the script under this text I save the player data

 function dataService.dataSave(plr)
    if dataTree.DataStoreName then
        local ds = DSS:GetDataStore(dataTree.DataStoreName)
        
        local savedata = {}
        
        for i, child in plr:GetChildren() do
            for j, folder in dataTree.Folders do
                if folder.Name ==  child.Name then
                    for i, v in folder.Values do
                        if v.Save then
                            savedata[v.Name] = child[v.Name].Value
                        end
                    end
                end
            end
        end

        local success, err = pcall(function()
            ds:SetAsync(plr.UserId, savedata)
        end)

        if not success then
            warn("Save failed for", plr.Name, err)
        end
    end
    task.wait()
end

and here im calling the function

 PLRS.PlayerRemoving:Connect(function(plr)
    dataService.dataSave(plr)
end)

Everytime I leave the game tells me they put it in queue cause there were to many saves or sum.

#

What i dont understand is im calling this function one time and it overflows

#

nvm im so fucking stupid

fallen jackal
#

BindToClose

#

Use BindToClose and loop thru all the players and save their data

#

More useful when you’re testing InStudio

#

But might be useful when you shutdown servers

steady dock
#

ahh thats true, you need to delay when in studio. cause studio closes quicker than the roblox client

atomic turtle
#

the problem was that i have this module and i forgot to delete the playerRemoving from there cause i was running the function also from an extern script so it triggered twice wehn players were leaving

fallen jackal
#

so its fixed ?

atomic turtle
#

yeah it was just that i had .PlayerRemoving twice connected to the function