Breaking Changes
- Now you can get profile type from
dataStoreService.profile (exported type)
- Reworked methods:
profile:add(key, delta) and profile:set(key, value) instead of dataStoreService.add(player, key, delta) and dataStoreService.set(player, key, value)
- Added paths for
IN_PLAYER entries instead of parent
getProfile(player) now returns a wrapped profile object, not profile.Data. Access raw data via profile.Data.<key> or use profile:add() / profile:set()
- And a few little fixes
Examples
Before:
local dataStoreService = require("./../Global/DataStoreService")
return {
update = function()
for _, plr in game:GetService("Players"):GetPlayers() do
local profile = dataStoreService.getProfile(plr)
if not profile then continue end
profile.Coins += 1
dataStoreService.updateData(plr) -- to update leaderstats and other folders in player Instance
end
end,
playerDataLoaded = function(plr: Player, profile: any)
dataStoreService.set(plr, "Coins", 100)
dataStoreService.add(plr, "Coins", math.random(-100, 100))
end,
}
After:
local dataStoreService = require("./../Global/DataStoreService")
return {
update = function()
for _, plr in game:GetService("Players"):GetPlayers() do
local profile = dataStoreService.getProfile(plr)
if not profile then continue end
profile.Data.Coins += 1
profile:updateFolders() -- to update leaderstats and other folders in player Instance
end
end,
playerDataLoaded = function(plr: Player, profile: dataStoreService.profile)
profile:set("Coins", 100)
profile:add("Coins", math.random(-100, 100))
end,
}