Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function SaveData(player)
- local data = {}
- local count = 0
- local success, errorMsg = pcall(function()
- for i, folder in pairs(player:GetChildren()) do
- data[folder.Name] = {}
- for i, item in pairs(folder:GetChildren()) do
- data[folder.Name][item.Name] = item.Value
- end
- end
- dataStore:SetAsync(player.UserId .. key, data)
- end)
- if not success then
- warn(errorMsg)
- wait(5)
- SaveData(player)
- end
- print("Saved data")
- print(data)
- end
- players.PlayerRemoving:Connect(SaveData)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement