PointsService

顯示已棄用項目

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

無法建立
服務
已棄用

PointsService 類型控制點數。

點數是一種獎勵系統,用於在 Roblox 中展示玩家的成就和參與。點數的獎勵由遊戲開發者獨自決定。

概要

活動

屬性

方法

活動

PointsAwarded

這個事件會在點被成功給予玩家時發生,並且還會傳送更新的點數給玩家和所有遊戲。

當玩家獲得點數時,下列範例會列出用戶名和其新點數餘額。如果 Roblox 帳號獲得了三十點 (並且沒有開始時)

玩家:1 已現在在當前遊戲中獲得 30 點 (+30) 點,現在將他們的總餘額

將被列印。


local function pointsAwarded(userId, pointsAwarded, userBalanceInGame, userTotalBalance)
print("User: " .. userId .. " has now earned " .. userBalanceInGame .. " (+" .. pointsAwarded ..") points in the current game, now making their total balance " .. userTotalBalance)
end
game:GetService("PointsService").PointsAwarded:Connect(pointsAwarded)

參數

userId: number
pointsAwarded: number
userBalanceInGame: number
userTotalBalance: number

範例程式碼

When a player is awarded points successfully the below example would print the userId and their new point balance. If, for example, the Roblox account was awarded thirty points (and had none to begin with) "User: 1 has now earned 30 (+30) points in the current game, now making their total balance 30" would be printed.

PointsService.PointsAwarded

local PointsService = game:GetService("PointsService")
local function onPointsAwarded(userId, pointsAwarded, userBalanceInGame, userTotalBalance)
print(
"User:",
userId,
"has now earned",
userBalanceInGame,
"(+",
pointsAwarded,
") points in the current game, now making their total balance",
userTotalBalance
)
end
PointsService.PointsAwarded:Connect(onPointsAwarded)