Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DSS = game:GetService("DataStoreService"):GetDataStore("Test")
- function getKey(plr)
- local key = "id_"..plr.UserId
- return key
- end
- function generateDTable(plr)
- local data = {
- Val = plr.leaderstats.val.Value
- }
- return data
- end
- function saveData(plr)
- local key = getKey(plr)
- local data = generateDTable(plr)
- DSS:SetAsync(key, data)
- end
- function loadData(plr)
- local key = getKey(plr)
- local data = DSS:GetAsync(key)
- giveData(plr,data)
- end
- function giveData(plr, data)
- plr.leaderstats.Val.Value = data.Val
- end
Advertisement
Add Comment
Please, Sign In to add comment