Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function LoadData(player)
- for i, v in pairs(playerData:GetChildren()) do
- v:Clone().Parent = player
- end
- local data
- local success, errorMsg = pcall(function()
- data = dataStore:GetAsync(player.UserId .. key)
- for key, folder in pairs(data) do
- if key == "leaderstats" then
- for item, amount in pairs(folder) do
- if item == "Coins" then
- player.leaderstats.Coins.Value = amount
- elseif item == "Diamonds" then
- player.leaderstats.Diamonds.Value = amount
- end
- end
- end
- if key == "Areas" then
- for item, _ in pairs(folder) do
- if not player.Areas:FindFirstChild(item) then
- local value = Instance.new("StringValue", player.Areas)
- value.Name = item
- area:FireClient(player, workspace.Areas[value.Name].Barrier)
- end
- end
- end
- if key == "Pets" then
- for id, petName in pairs(folder) do
- local pet = Instance.new("StringValue", player.Pets)
- pet.Name = petName
- pet.Value = id
- createTemplate:FireClient(player, petName, id)
- end
- end
- end
- print("Loaded data")
- print(data)
- end)
- if not success then
- warn(errorMsg)
- wait(5)
- LoadData(player)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement