Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //this is the general format of the player savedata
- local data = {}
- game.Players.PlayerAdded:Connect(function(player)
- local plrDat = DataStore:GetAsync(player.UserId)
- if plrDat ~= nil then
- data[tostring(player.UserId)] = plrDat
- else
- data[tostring(player.UserId)] = {
- ['Tier'] = 1,
- ['Level'] = 1,
- ['EXP'] = 0,
- ['Name'] = "John Doe",
- ['Appearance'] = {//basically texture values and colors converted to hashes with integers here},
- ['Genetics'] = {
- //redacted
- },
- ['PrimaryTown'] = "Dragan",
- ['Statistics'] = {
- ['Aptitude'] = 1,
- ['Intelligence'] = 1,
- ['Power'] = 1,
- ['Strength'] = 1,
- ['Agility'] = 1,
- },
- ['StatisticCache'] = { //stats earned but not redeemed yet
- ['Aptitude'] = 0,
- ['Intelligence'] = 0,
- ['Power'] = 0,
- ['Strength'] = 0,
- ['Agility'] = 0,
- },
- ['Abilities'] = { },
- ['EquippedAbilities'] = {
- ['Slot1'] = nil,
- ['Slot2'] = nil,
- ['Slot3'] = nil,
- ['Slot4'] = nil,
- },
- ['Perks'] = { },
- ['EquippedPerks'] = {
- ['Perk1'] = nil,
- ['Perk2'] = nil,
- ['Perk3'] = nil,
- ['Perk4'] = nil,
- ['Perk5'] = nil,
- },
- }
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- DataStore:SetAsync(player.UserId, data[tostring(player.UserId)])
- end)
- --alternatively with UpdateAsync but the problem still occurs and I don't think it's any better than SetAsync in this context
- --[[game.Players.PlayerRemoving:Connect(function(player)
- DataStore:UpdateAsync(player.UserId, function(oldData)
- return data[tostring(player.UserId)]
- end)
- end)]]
Advertisement
Add Comment
Please, Sign In to add comment