I’m working with data saves and when the player leaves the game the code should “scoop up” all the data and it does that successfully but for some reason some of it doesn’t get added to the dictionary that is going to be saved
I never experienced this… My best guess would be that it’s something to do with player leaving but I really don’t have a clue
Heres some code:
game.Players.PlayerRemoving:Connect(function(plr)
local count = 0
local dataToBeSaved = {
Tutorial = plr.dataFolder.Tutorial.Value,
Cash = plr.leaderstats.Cash.Value,
Donations = plr.leaderstats.Donations.Value
}
for _,rebirthFolder in pairs(plr.dataFolder:GetChildren()) do
local rebirthNumber = string.sub(rebirthFolder.Name, string.len(rebirthFolder.Name))
for _, folderWithData in pairs(rebirthFolder:GetChildren()) do
for _,plrBoolValue in pairs(folderWithData:GetChildren()) do
if plrBoolValue:IsA("BoolValue") then
local dataNameNumber = string.sub(plrBoolValue.Name, string.len(plrBoolValue.Name))
local name = folderWithData.Name .. dataNameNumber * rebirthNumber
print(name)
dataToBeSaved[name] = plrBoolValue.Value
count += 1
end
end
end
end
if count == 90 then --Unreliable fix later
print(dataToBeSaved)
local succes,err = pcall(function()
userData:SetAsync(PUID, dataToBeSaved)
end)
if succes then
print("Data saved successfully")
else
print("Data failed to save, please open a ticket in discord!")
end
end
end)
Also some screenshots of what it prints:
all the names that are supposed to be saved:
a lot
And what gets put in the table: