Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Player Data Service
- -- Quoteory
- -- August 4, 2019
- local PlayerDataService = {Client = {}}
- local serverScriptService
- local DataStore2
- local tableUtil
- local defaultDataTable = {Stats = {Rank = 1, RankEXP = 0}, Plot = {Type = 1}} -- metatable
- local PLAYER_DATASTORE = "PlayerData2"
- local playerDataCaches = {}
- function PlayerDataService:SetupData(Player)
- local dataStore = DataStore2(PLAYER_DATASTORE, Player)
- local loadedData = dataStore:GetTable(defaultDataTable)
- local Temp = {}
- tableUtil.Print(loadedData, " ", true)
- playerDataCaches[Player] = {dataCache = loadedData, tempCache = Temp}
- end
- function PlayerDataService:GetData(Player)
- return playerDataCaches[Player]
- end
- function PlayerDataService:SaveData(Player)
- local dataStore = DataStore2(PLAYER_DATASTORE, Player)
- dataStore:Set(playerDataCaches[Player].dataCache)
- end
- function PlayerDataService:ClearData(Player)
- playerDataCaches[Player] = nil
- end
- function PlayerDataService:Start()
- end
- function PlayerDataService:Init()
- tableUtil = self.Shared.TableUtil
- serverScriptService = game:GetService("ServerScriptService")
- DataStore2 = require(serverScriptService:WaitForChild("DataStore2"))
- end
- return PlayerDataService
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement