πͺ DataStoreService
Service for accessing and storing persistent data for a map.
-- Double the score of a player whenever they kill an entity
local function doubleScore(current)
return current * 2
end
Events.EntityDeath(function (event)
local killerPlayer = event.killer:getPlayer()
if (killerPlayer == nil) then
return
end
task.spawn(function()
local currentValue = DataStoreService.getAsync(killerPlayer.userId)
if (currentValue == nil) then
currentValue = 1
end
DataStoreService.setAsync(killerPlayer.userId, doubleScore(currentValue))
end)
end)Functions
getAsync(key: string | number): any
setAsync(key: string | number, value: any): bool
incrementAsync(key: string | number, amount: number): bool
removeAsync(key: string | number): bool
Last updated