How to reward players for buying your avatar items

Purchase finished events for avatar items come from the client. How to check ownership with PlayerOwnsAssetAsync and pay each item's reward once.

criticalLuaudit check: unverified-avatar-item-rewards

What it looks like

The game rewards players for buying its avatar items, such as a hat or a bundle from the catalogue, and pays out when the purchase prompt reports a purchase. It never asks Roblox whether the player now owns the item.

Luau
MarketplaceService.PromptPurchaseFinished:Connect(function(player, assetId, isPurchased)
	if isPurchased and itemRewards[assetId] then
		profile.Coins += itemRewards[assetId]
	end
end)

What an exploiter could do

They make the finished event fire, or fire the claim remote, saying they bought the item, and collect the reward without spending any Robux. Without a once-per-item record, a player who really bought it can claim the reward again and again.

How to fix it

  • Keep a server table of rewarded item ids and their rewards.
  • When a finished event arrives for one of them, call PlayerOwnsAssetAsync or PlayerOwnsBundleAsync in pcall, and grant only if it returns true.
  • Record each item's reward in the player's saved data and skip items already claimed.
  • Treat a failed ownership call as not owned. The player can claim again later, for example from a "claim" button that runs the same check.

Vulnerable example

Vulnerable
local MarketplaceService = game:GetService("MarketplaceService")
local PlayerData = require(script.Parent.PlayerData)

local itemRewards: { [number]: number } = {
	[2222222] = 500,
	[3333333] = 1000,
}

MarketplaceService.PromptPurchaseFinished:Connect(function(player: Player, assetId: number, isPurchased: boolean)
	local reward = itemRewards[assetId]
	local profile = PlayerData.get(player)
	if isPurchased and reward and profile then
		profile.Coins += reward
	end
end)

Fixed example

Fixed
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local PlayerData = require(script.Parent.PlayerData)

local itemRewards: { [number]: number } = {
	[2222222] = 500,
	[3333333] = 1000,
}
local checking: { [Player]: boolean } = {}

MarketplaceService.PromptPurchaseFinished:Connect(function(player: Player, assetId: number)
	local reward = itemRewards[assetId]
	local profile = PlayerData.get(player)
	local key = "Item:" .. assetId
	if not reward or not profile or profile.Claimed[key] or checking[player] then
		return
	end
	checking[player] = true
	local ok, owned = pcall(MarketplaceService.PlayerOwnsAssetAsync, MarketplaceService, player, assetId)
	checking[player] = nil
	if ok and owned == true and not profile.Claimed[key] then
		profile.Claimed[key] = true
		profile.Coins += reward
	end
end)

Players.PlayerRemoving:Connect(function(player)
	checking[player] = nil
end)

How to spot this in your own scripts, and the cases that only look like it, are part of the Luaudit check your AI runs.