Hi Creators,
PointsService
has been deprecated for years and we are now announcing to retire it on June 30th, 2023. If you still want to keep the corresponding features in your experience, we suggest updating to use Data Stores instead.
After June 30th, all AwardPoints()
will return success but not update the backend. All get APIs (GetAwardablePoints()
,GetGamePointBalance()
,GetPointBalance()
) will return 0.
We realize that despite the service being deprecated some experiences still use it in a meaningful way therefore we offer to migrate data from PointsService
to a Roblox data store of your choice for experiences that need it.
Migration
In order to have PointsService
data migrated, you need to complete the following steps before May 31st, 2023:
-
Incorporate the migration module into your experience (source code below). This module should be a drop-in replacement for the
PointsService
in most cases. -
Fill out this form to let us know that your experience needs to have data migrated.
Source Code
Below is the source code of the migration module. It should be added as a ModuleScript
in your experience.
-- change the datastore name as desired
local datastoreName = "_rbx_UserPoints"
local pointsAwarded = Instance.new("BindableEvent")
local ds = game:GetService("DataStoreService"):GetOrderedDataStore(datastoreName)
local ps = game:GetService("PointsService")
return {
AwardPoints = function(self: any, userId: number, amount: number)
if userId <= 0 then
error('User id must be positive')
end
if amount <= 0 then
error('Point amount must be positive')
end
-- optimistically assume that the user has already been migrated
local finalPoints = ds:UpdateAsync(userId, function (currentPoints: number?): number?
if not currentPoints then
-- oops, not actually migrated
return nil
end
return currentPoints + amount
end)
if not finalPoints then
-- this user has not been migrated, migrate it now
local legacyPoints = ps:GetGamePointBalance(userId)
finalPoints = ds:UpdateAsync(userId, function (currentPoints: number?): number
if not currentPoints then
-- still not migrated, add point amount from the legacy system
-- to the amount of points awarded
return legacyPoints + amount
else
-- the user must have been migrated from another instance;
-- disregard legacy points and proceed as usual
return currentPoints + amount
end
end)
end
if finalPoints then
pointsAwarded:Fire(userId, amount, finalPoints, finalPoints)
end
end,
GetGamePointBalance = function(self: any, userId: number): number
if userId <= 0 then
error('User id must be positive')
end
-- optimistically assume the user has been migrated
local points = ds:GetAsync(userId)
if not points then
-- user not migrated yet, query legacy system
points = ps:GetGamePointBalance(userId)
end
return points
end,
GetPointBalance = function(self: any, userId: number): number
return 0
end,
GetAwardablePoints = function(self: any): number
return 2^31 - 1
end,
PointsAwarded = pointsAwarded.Event,
}
To use the module, add the following line to the beginning of each script file that uses PointsService
:
local PointsServiceWrapper = require(script.Parent.PointsServiceWrapper)
Then replace each call to PointsService:AwardPoints
with PointsServiceWrapper:AwardPoints
and each call to PointsService:GetGamePointBalance
with PointsServiceWrapper:GetGamePointBalance
.
FAQ
What happens if I don’t fill out the migration request form?
- If you don’t migrate, the points data for your experience will be lost.
PointsService
data will only be migrated for experiences indicated on the migration form.
What happens if I fill out the form but don’t incorporate the migration module into my experience?
- The migration module is required to ensure that data is migrated correctly and no data is lost. We cannot guarantee the completeness of the migrated data if the migration module is not used.
Please let us know if you have any questions or concerns.
Sincerely,
The Roblox Creator Services Team